diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-03-12 02:22:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-12 02:22:41 +0000 |
| commit | d0911786c95dfa7a63ec348bb4a9870da12f62e4 (patch) | |
| tree | c2ee731b2fcb53504dbade8077084bf935197c06 /src/Zcu/PerThread.zig | |
| parent | a0401cf3e4aed014abc1189890f4c1c756a12737 (diff) | |
| parent | 4129f7ff5a03cb3cd85a3ad5e3360098ab8ed796 (diff) | |
| download | zig-d0911786c95dfa7a63ec348bb4a9870da12f62e4.tar.gz zig-d0911786c95dfa7a63ec348bb4a9870da12f62e4.zip | |
Merge pull request #22397 from Techatrix/type-safe-ast
improve type safety of std.zig.Ast
Diffstat (limited to 'src/Zcu/PerThread.zig')
| -rw-r--r-- | src/Zcu/PerThread.zig | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 699315835a..5823fb0f18 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -841,7 +841,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu .comptime_reason = .{ .reason = .{ .src = .{ .base_node_inst = comptime_unit.zir_index, - .offset = .{ .token_offset = 0 }, + .offset = .{ .token_offset = .zero }, }, .r = .{ .simple = .comptime_keyword }, } }, @@ -1042,11 +1042,11 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr const zir_decl = zir.getDeclaration(inst_resolved.inst); assert(old_nav.is_usingnamespace == (zir_decl.kind == .@"usingnamespace")); - const ty_src = block.src(.{ .node_offset_var_decl_ty = 0 }); - const init_src = block.src(.{ .node_offset_var_decl_init = 0 }); - const align_src = block.src(.{ .node_offset_var_decl_align = 0 }); - const section_src = block.src(.{ .node_offset_var_decl_section = 0 }); - const addrspace_src = block.src(.{ .node_offset_var_decl_addrspace = 0 }); + const ty_src = block.src(.{ .node_offset_var_decl_ty = .zero }); + const init_src = block.src(.{ .node_offset_var_decl_init = .zero }); + const align_src = block.src(.{ .node_offset_var_decl_align = .zero }); + const section_src = block.src(.{ .node_offset_var_decl_section = .zero }); + const addrspace_src = block.src(.{ .node_offset_var_decl_addrspace = .zero }); block.comptime_reason = .{ .reason = .{ .src = init_src, @@ -1135,7 +1135,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr break :l zir.nullTerminatedString(zir_decl.lib_name); } else null; if (lib_name) |l| { - const lib_name_src = block.src(.{ .node_offset_lib_name = 0 }); + const lib_name_src = block.src(.{ .node_offset_lib_name = .zero }); try sema.handleExternLibName(&block, lib_name_src, l); } break :val .fromInterned(try pt.getExtern(.{ @@ -1233,7 +1233,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr } if (zir_decl.linkage == .@"export") { - const export_src = block.src(.{ .token_offset = @intFromBool(zir_decl.is_pub) }); + const export_src = block.src(.{ .token_offset = @enumFromInt(@intFromBool(zir_decl.is_pub)) }); const name_slice = zir.nullTerminatedString(zir_decl.name); const name_ip = try ip.getOrPutString(gpa, pt.tid, name_slice, .no_embedded_nulls); try sema.analyzeExport(&block, export_src, .{ .name = name_ip }, nav_id); @@ -1414,7 +1414,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr const zir_decl = zir.getDeclaration(inst_resolved.inst); assert(old_nav.is_usingnamespace == (zir_decl.kind == .@"usingnamespace")); - const ty_src = block.src(.{ .node_offset_var_decl_ty = 0 }); + const ty_src = block.src(.{ .node_offset_var_decl_ty = .zero }); block.comptime_reason = .{ .reason = .{ .src = ty_src, @@ -2743,7 +2743,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE if (sema.fn_ret_ty_ies) |ies| { sema.resolveInferredErrorSetPtr(&inner_block, .{ .base_node_inst = inner_block.src_base_inst, - .offset = Zcu.LazySrcLoc.Offset.nodeOffset(0), + .offset = Zcu.LazySrcLoc.Offset.nodeOffset(.zero), }, ies) catch |err| switch (err) { error.ComptimeReturn => unreachable, error.ComptimeBreak => unreachable, @@ -2762,7 +2762,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE // result in circular dependency errors. // TODO: this can go away once we fix backends having to resolve `StackTrace`. // The codegen timing guarantees that the parameter types will be populated. - sema.resolveFnTypes(fn_ty, inner_block.nodeOffset(0)) catch |err| switch (err) { + sema.resolveFnTypes(fn_ty, inner_block.nodeOffset(.zero)) catch |err| switch (err) { error.ComptimeReturn => unreachable, error.ComptimeBreak => unreachable, else => |e| return e, |
