authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-29 18:44:25+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:08+00:00
log650185692dc6fb6b9c2c4e591d37cb94410972e1
tree0d70c9462da40fe604cb674a17e5ea4b5ae1f564
parent8eefe86939e917e4e85049325bff8c5a43f50f95
signaturelock-open Commit is signed but in an unrecognized format.

compiler: merge struct default value resolution into layout resolution

This actually doesn't cause any dependency loops in std, which is pretty much my benchmark for it being acceptable. This can be reverted if it turns out to be problematic, but for now, let's err on the side of language simplicity. To be clear, this *does* regress some cases which previously worked: I will have to remove some behavior tests as a result of this commit. To be honest, the tests which look to be failing as a result of this are things which I think are generally unadvisable; I actually reckon a bit more friction to use default field values in non-trivial ways might be a good thing to stop people from misusing them as much. Struct fields should very rarely have default values; about the only common situation where they make sense is "options" structs.

15 files changed, 120 insertions(+), 422 deletions(-)

src/Air/Liveness.zig+4-4
...@@ -153,8 +153,8 @@ pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Li...@@ -153,8 +153,8 @@ pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Li
153 usize,153 usize,
154 (air.instructions.len * bpi + @bitSizeOf(usize) - 1) / @bitSizeOf(usize),154 (air.instructions.len * bpi + @bitSizeOf(usize) - 1) / @bitSizeOf(usize),
155 ),155 ),
156 .extra = .{},156 .extra = .empty,
157 .special = .{},157 .special = .empty,
158 .intern_pool = intern_pool,158 .intern_pool = intern_pool,
159 };159 };
160 errdefer gpa.free(a.tomb_bits);160 errdefer gpa.free(a.tomb_bits);
...@@ -175,7 +175,7 @@ pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Li...@@ -175,7 +175,7 @@ pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Li
175 var data: LivenessPassData(.main_analysis) = .{};175 var data: LivenessPassData(.main_analysis) = .{};
176 defer data.deinit(gpa);176 defer data.deinit(gpa);
177 data.old_extra = a.extra;177 data.old_extra = a.extra;
178 a.extra = .{};178 a.extra = .empty;
179 try analyzeBody(&a, .main_analysis, &data, main_body);179 try analyzeBody(&a, .main_analysis, &data, main_body);
180 assert(data.live_set.count() == 0);180 assert(data.live_set.count() == 0);
181 }181 }
...@@ -1360,7 +1360,7 @@ fn analyzeInstSwitchBr(...@@ -1360,7 +1360,7 @@ fn analyzeInstSwitchBr(
1360 const mirrored_deaths = try gpa.alloc(DeathList, ncases + 1);1360 const mirrored_deaths = try gpa.alloc(DeathList, ncases + 1);
1361 defer gpa.free(mirrored_deaths);1361 defer gpa.free(mirrored_deaths);
13621362
1363 @memset(mirrored_deaths, .{});1363 @memset(mirrored_deaths, .empty);
1364 defer for (mirrored_deaths) |*md| md.deinit(gpa);1364 defer for (mirrored_deaths) |*md| md.deinit(gpa);
13651365
1366 {1366 {
src/Compilation.zig+2-7
...@@ -3713,7 +3713,6 @@ const Header = extern struct {...@@ -3713,7 +3713,6 @@ const Header = extern struct {
3713 nav_val_deps_len: u32,3713 nav_val_deps_len: u32,
3714 nav_ty_deps_len: u32,3714 nav_ty_deps_len: u32,
3715 type_layout_deps_len: u32,3715 type_layout_deps_len: u32,
3716 struct_defaults_deps_len: u32,
3717 func_ies_deps_len: u32,3716 func_ies_deps_len: u32,
3718 zon_file_deps_len: u32,3717 zon_file_deps_len: u32,
3719 embed_file_deps_len: u32,3718 embed_file_deps_len: u32,
...@@ -3763,7 +3762,6 @@ pub fn saveState(comp: *Compilation) !void {...@@ -3763,7 +3762,6 @@ pub fn saveState(comp: *Compilation) !void {
3763 .nav_val_deps_len = @intCast(ip.nav_val_deps.count()),3762 .nav_val_deps_len = @intCast(ip.nav_val_deps.count()),
3764 .nav_ty_deps_len = @intCast(ip.nav_ty_deps.count()),3763 .nav_ty_deps_len = @intCast(ip.nav_ty_deps.count()),
3765 .type_layout_deps_len = @intCast(ip.type_layout_deps.count()),3764 .type_layout_deps_len = @intCast(ip.type_layout_deps.count()),
3766 .struct_defaults_deps_len = @intCast(ip.struct_defaults_deps.count()),
3767 .func_ies_deps_len = @intCast(ip.func_ies_deps.count()),3765 .func_ies_deps_len = @intCast(ip.func_ies_deps.count()),
3768 .zon_file_deps_len = @intCast(ip.zon_file_deps.count()),3766 .zon_file_deps_len = @intCast(ip.zon_file_deps.count()),
3769 .embed_file_deps_len = @intCast(ip.embed_file_deps.count()),3767 .embed_file_deps_len = @intCast(ip.embed_file_deps.count()),
...@@ -3788,7 +3786,7 @@ pub fn saveState(comp: *Compilation) !void {...@@ -3788,7 +3786,7 @@ pub fn saveState(comp: *Compilation) !void {
3788 },3786 },
3789 });3787 });
37903788
3791 try bufs.ensureTotalCapacityPrecise(26 + 9 * pt_headers.items.len);3789 try bufs.ensureTotalCapacityPrecise(24 + 9 * pt_headers.items.len);
3792 addBuf(&bufs, mem.asBytes(&header));3790 addBuf(&bufs, mem.asBytes(&header));
3793 addBuf(&bufs, @ptrCast(pt_headers.items));3791 addBuf(&bufs, @ptrCast(pt_headers.items));
37943792
...@@ -3800,8 +3798,6 @@ pub fn saveState(comp: *Compilation) !void {...@@ -3800,8 +3798,6 @@ pub fn saveState(comp: *Compilation) !void {
3800 addBuf(&bufs, @ptrCast(ip.nav_ty_deps.values()));3798 addBuf(&bufs, @ptrCast(ip.nav_ty_deps.values()));
3801 addBuf(&bufs, @ptrCast(ip.type_layout_deps.keys()));3799 addBuf(&bufs, @ptrCast(ip.type_layout_deps.keys()));
3802 addBuf(&bufs, @ptrCast(ip.type_layout_deps.values()));3800 addBuf(&bufs, @ptrCast(ip.type_layout_deps.values()));
3803 addBuf(&bufs, @ptrCast(ip.struct_defaults_deps.keys()));
3804 addBuf(&bufs, @ptrCast(ip.struct_defaults_deps.values()));
3805 addBuf(&bufs, @ptrCast(ip.func_ies_deps.keys()));3801 addBuf(&bufs, @ptrCast(ip.func_ies_deps.keys()));
3806 addBuf(&bufs, @ptrCast(ip.func_ies_deps.values()));3802 addBuf(&bufs, @ptrCast(ip.func_ies_deps.values()));
3807 addBuf(&bufs, @ptrCast(ip.zon_file_deps.keys()));3803 addBuf(&bufs, @ptrCast(ip.zon_file_deps.keys()));
...@@ -4481,7 +4477,7 @@ pub fn addModuleErrorMsg(...@@ -4481,7 +4477,7 @@ pub fn addModuleErrorMsg(
4481 const root_name: ?[]const u8 = switch (ref.referencer.unwrap()) {4477 const root_name: ?[]const u8 = switch (ref.referencer.unwrap()) {
4482 .@"comptime" => "comptime",4478 .@"comptime" => "comptime",
4483 .nav_val, .nav_ty => |nav| ip.getNav(nav).name.toSlice(ip),4479 .nav_val, .nav_ty => |nav| ip.getNav(nav).name.toSlice(ip),
4484 .type_layout, .struct_defaults => |ty| Type.fromInterned(ty).containerTypeName(ip).toSlice(ip),4480 .type_layout => |ty| Type.fromInterned(ty).containerTypeName(ip).toSlice(ip),
4485 .func => |f| ip.getNav(zcu.funcInfo(f).owner_nav).name.toSlice(ip),4481 .func => |f| ip.getNav(zcu.funcInfo(f).owner_nav).name.toSlice(ip),
4486 .memoized_state => null,4482 .memoized_state => null,
4487 };4483 };
...@@ -5251,7 +5247,6 @@ fn processOneJob(tid: Zcu.PerThread.Id, comp: *Compilation, job: Job) JobError!v...@@ -5251,7 +5247,6 @@ fn processOneJob(tid: Zcu.PerThread.Id, comp: *Compilation, job: Job) JobError!v
5251 .nav_ty => |nav| pt.ensureNavTypeUpToDate(nav),5247 .nav_ty => |nav| pt.ensureNavTypeUpToDate(nav),
5252 .nav_val => |nav| pt.ensureNavValUpToDate(nav),5248 .nav_val => |nav| pt.ensureNavValUpToDate(nav),
5253 .type_layout => |ty| pt.ensureTypeLayoutUpToDate(.fromInterned(ty)),5249 .type_layout => |ty| pt.ensureTypeLayoutUpToDate(.fromInterned(ty)),
5254 .struct_defaults => |ty| pt.ensureStructDefaultsUpToDate(.fromInterned(ty)),
5255 .memoized_state => |stage| pt.ensureMemoizedStateUpToDate(stage),5250 .memoized_state => |stage| pt.ensureMemoizedStateUpToDate(stage),
5256 .func => |func| pt.ensureFuncBodyUpToDate(func),5251 .func => |func| pt.ensureFuncBodyUpToDate(func),
5257 };5252 };
src/IncrementalDebugServer.zig+1-3
...@@ -307,7 +307,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const...@@ -307,7 +307,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
307 switch (dependee) {307 switch (dependee) {
308 .src_hash, .namespace, .namespace_name, .zon_file, .embed_file => try w.print("{f}", .{zcu.fmtDependee(dependee)}),308 .src_hash, .namespace, .namespace_name, .zon_file, .embed_file => try w.print("{f}", .{zcu.fmtDependee(dependee)}),
309 .nav_val, .nav_ty => |nav| try w.print("{t} {d}", .{ dependee, @intFromEnum(nav) }),309 .nav_val, .nav_ty => |nav| try w.print("{t} {d}", .{ dependee, @intFromEnum(nav) }),
310 .type_layout, .struct_defaults, .func_ies => |ip_index| try w.print("{t} {d}", .{ dependee, @intFromEnum(ip_index) }),310 .type_layout, .func_ies => |ip_index| try w.print("{t} {d}", .{ dependee, @intFromEnum(ip_index) }),
311 .memoized_state => |stage| try w.print("memoized_state {s}", .{@tagName(stage)}),311 .memoized_state => |stage| try w.print("memoized_state {s}", .{@tagName(stage)}),
312 }312 }
313 try w.writeByte('\n');313 try w.writeByte('\n');
...@@ -374,8 +374,6 @@ fn parseAnalUnit(str: []const u8) ?AnalUnit {...@@ -374,8 +374,6 @@ fn parseAnalUnit(str: []const u8) ?AnalUnit {
374 return .wrap(.{ .nav_ty = @enumFromInt(parseIndex(idx_str) orelse return null) });374 return .wrap(.{ .nav_ty = @enumFromInt(parseIndex(idx_str) orelse return null) });
375 } else if (std.mem.eql(u8, kind, "type_layout")) {375 } else if (std.mem.eql(u8, kind, "type_layout")) {
376 return .wrap(.{ .type_layout = @enumFromInt(parseIndex(idx_str) orelse return null) });376 return .wrap(.{ .type_layout = @enumFromInt(parseIndex(idx_str) orelse return null) });
377 } else if (std.mem.eql(u8, kind, "struct_defaults")) {
378 return .wrap(.{ .struct_defaults = @enumFromInt(parseIndex(idx_str) orelse return null) });
379 } else if (std.mem.eql(u8, kind, "func")) {377 } else if (std.mem.eql(u8, kind, "func")) {
380 return .wrap(.{ .func = @enumFromInt(parseIndex(idx_str) orelse return null) });378 return .wrap(.{ .func = @enumFromInt(parseIndex(idx_str) orelse return null) });
381 } else if (std.mem.eql(u8, kind, "memoized_state")) {379 } else if (std.mem.eql(u8, kind, "memoized_state")) {
src/InternPool.zig+5-82
...@@ -54,9 +54,6 @@ func_ies_deps: std.AutoArrayHashMapUnmanaged(Index, DepEntry.Index),...@@ -54,9 +54,6 @@ func_ies_deps: std.AutoArrayHashMapUnmanaged(Index, DepEntry.Index),
54/// Dependencies on the resolved layout of a `struct`, `union`, or `enum` type.54/// Dependencies on the resolved layout of a `struct`, `union`, or `enum` type.
55/// Value is index into `dep_entries` of the first dependency on this type's layout.55/// Value is index into `dep_entries` of the first dependency on this type's layout.
56type_layout_deps: std.AutoArrayHashMapUnmanaged(Index, DepEntry.Index),56type_layout_deps: std.AutoArrayHashMapUnmanaged(Index, DepEntry.Index),
57/// Dependencies on the resolved default field values of a `struct` type.
58/// Value is index into `dep_entries` of the first dependency on this type's inits.
59struct_defaults_deps: std.AutoArrayHashMapUnmanaged(Index, DepEntry.Index),
60/// Dependencies on a ZON file. Triggered by `@import` of ZON.57/// Dependencies on a ZON file. Triggered by `@import` of ZON.
61/// Value is index into `dep_entries` of the first dependency on this ZON file.58/// Value is index into `dep_entries` of the first dependency on this ZON file.
62zon_file_deps: std.AutoArrayHashMapUnmanaged(FileIndex, DepEntry.Index),59zon_file_deps: std.AutoArrayHashMapUnmanaged(FileIndex, DepEntry.Index),
...@@ -111,7 +108,6 @@ pub const empty: InternPool = .{...@@ -111,7 +108,6 @@ pub const empty: InternPool = .{
111 .nav_ty_deps = .empty,108 .nav_ty_deps = .empty,
112 .func_ies_deps = .empty,109 .func_ies_deps = .empty,
113 .type_layout_deps = .empty,110 .type_layout_deps = .empty,
114 .struct_defaults_deps = .empty,
115 .zon_file_deps = .empty,111 .zon_file_deps = .empty,
116 .embed_file_deps = .empty,112 .embed_file_deps = .empty,
117 .namespace_deps = .empty,113 .namespace_deps = .empty,
...@@ -423,7 +419,6 @@ pub const AnalUnit = packed struct(u64) {...@@ -423,7 +419,6 @@ pub const AnalUnit = packed struct(u64) {
423 nav_val,419 nav_val,
424 nav_ty,420 nav_ty,
425 type_layout,421 type_layout,
426 struct_defaults,
427 func,422 func,
428 memoized_state,423 memoized_state,
429 };424 };
...@@ -437,8 +432,6 @@ pub const AnalUnit = packed struct(u64) {...@@ -437,8 +432,6 @@ pub const AnalUnit = packed struct(u64) {
437 nav_ty: Nav.Index,432 nav_ty: Nav.Index,
438 /// This `AnalUnit` resolves the layout of the given `struct`, `union`, or `enum` type.433 /// This `AnalUnit` resolves the layout of the given `struct`, `union`, or `enum` type.
439 type_layout: InternPool.Index,434 type_layout: InternPool.Index,
440 /// This `AnalUnit` resolves the default field values of the given `struct` type.
441 struct_defaults: InternPool.Index,
442 /// This `AnalUnit` analyzes the body of the given runtime function.435 /// This `AnalUnit` analyzes the body of the given runtime function.
443 func: InternPool.Index,436 func: InternPool.Index,
444 /// This `AnalUnit` resolves all state which is memoized in fields on `Zcu`.437 /// This `AnalUnit` resolves all state which is memoized in fields on `Zcu`.
...@@ -858,7 +851,6 @@ pub const Dependee = union(enum) {...@@ -858,7 +851,6 @@ pub const Dependee = union(enum) {
858 /// Index is the function, not its IES.851 /// Index is the function, not its IES.
859 func_ies: Index,852 func_ies: Index,
860 type_layout: Index,853 type_layout: Index,
861 struct_defaults: Index,
862 zon_file: FileIndex,854 zon_file: FileIndex,
863 embed_file: Zcu.EmbedFile.Index,855 embed_file: Zcu.EmbedFile.Index,
864 namespace: TrackedInst.Index,856 namespace: TrackedInst.Index,
...@@ -912,7 +904,6 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI...@@ -912,7 +904,6 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI
912 .nav_ty => |x| ip.nav_ty_deps.get(x),904 .nav_ty => |x| ip.nav_ty_deps.get(x),
913 .func_ies => |x| ip.func_ies_deps.get(x),905 .func_ies => |x| ip.func_ies_deps.get(x),
914 .type_layout => |x| ip.type_layout_deps.get(x),906 .type_layout => |x| ip.type_layout_deps.get(x),
915 .struct_defaults => |x| ip.struct_defaults_deps.get(x),
916 .zon_file => |x| ip.zon_file_deps.get(x),907 .zon_file => |x| ip.zon_file_deps.get(x),
917 .embed_file => |x| ip.embed_file_deps.get(x),908 .embed_file => |x| ip.embed_file_deps.get(x),
918 .namespace => |x| ip.namespace_deps.get(x),909 .namespace => |x| ip.namespace_deps.get(x),
...@@ -987,7 +978,6 @@ pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, depend...@@ -987,7 +978,6 @@ pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, depend
987 .nav_ty => ip.nav_ty_deps,978 .nav_ty => ip.nav_ty_deps,
988 .func_ies => ip.func_ies_deps,979 .func_ies => ip.func_ies_deps,
989 .type_layout => ip.type_layout_deps,980 .type_layout => ip.type_layout_deps,
990 .struct_defaults => ip.struct_defaults_deps,
991 .zon_file => ip.zon_file_deps,981 .zon_file => ip.zon_file_deps,
992 .embed_file => ip.embed_file_deps,982 .embed_file => ip.embed_file_deps,
993 .namespace => ip.namespace_deps,983 .namespace => ip.namespace_deps,
...@@ -3326,15 +3316,6 @@ pub const LoadedStructType = struct {...@@ -3326,15 +3316,6 @@ pub const LoadedStructType = struct {
3326 /// compiler frontend resolves this by traversing the reference graph at the end of each update3316 /// compiler frontend resolves this by traversing the reference graph at the end of each update
3327 /// with `Zcu.resolveReferences` and hiding compile errors which arise from this analysis.3317 /// with `Zcu.resolveReferences` and hiding compile errors which arise from this analysis.
3328 want_layout: bool,3318 want_layout: bool,
3329 /// Initially `false`, and set to `true` once any dependency on or reference to the struct's
3330 /// default field values is encountered, after which it is never reset to `false`, even across
3331 /// incremental updates.
3332 ///
3333 /// This field is purely an optimization to avoid resolving the layout of types whose layouts
3334 /// are never demanded. If this field is `true` but the layout is not actually needed, the
3335 /// compiler frontend resolves this by traversing the reference graph at the end of each update
3336 /// with `Zcu.resolveReferences` and hiding compile errors which arise from this analysis.
3337 want_defaults: bool,
33383319
3339 // The remaining fields are only valid once the struct's layout is resolved.3320 // The remaining fields are only valid once the struct's layout is resolved.
3340 field_name_map: MapIndex,3321 field_name_map: MapIndex,
...@@ -3711,7 +3692,6 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -3711,7 +3692,6 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
3711 .packed_backing_mode = undefined,3692 .packed_backing_mode = undefined,
37123693
3713 .want_layout = extra.data.flags.want_layout,3694 .want_layout = extra.data.flags.want_layout,
3714 .want_defaults = extra.data.flags.want_defaults,
37153695
3716 .field_name_map = extra.data.field_name_map,3696 .field_name_map = extra.data.field_name_map,
3717 .field_names = field_names,3697 .field_names = field_names,
...@@ -3772,7 +3752,6 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -3772,7 +3752,6 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
3772 .packed_backing_mode = backing_mode,3752 .packed_backing_mode = backing_mode,
37733753
3774 .want_layout = extra.data.bits.want_layout,3754 .want_layout = extra.data.bits.want_layout,
3775 .want_defaults = extra.data.bits.want_defaults,
37763755
3777 .field_name_map = extra.data.field_name_map,3756 .field_name_map = extra.data.field_name_map,
3778 .field_names = field_names,3757 .field_names = field_names,
...@@ -5666,9 +5645,8 @@ pub const Tag = enum(u8) {...@@ -5666,9 +5645,8 @@ pub const Tag = enum(u8) {
5666 alignment: Alignment,5645 alignment: Alignment,
56675646
5668 want_layout: bool,5647 want_layout: bool,
5669 want_defaults: bool,
56705648
5671 _: u15 = 0,5649 _: u16 = 0,
5672 };5650 };
5673 };5651 };
56745652
...@@ -5693,12 +5671,11 @@ pub const Tag = enum(u8) {...@@ -5693,12 +5671,11 @@ pub const Tag = enum(u8) {
5693 field_name_map: MapIndex,5671 field_name_map: MapIndex,
56945672
5695 const Bits = packed struct(u32) {5673 const Bits = packed struct(u32) {
5696 captures_len: enum(u30) {5674 captures_len: enum(u31) {
5697 reified = std.math.maxInt(u30),5675 reified = std.math.maxInt(u31),
5698 _,5676 _,
5699 },5677 },
5700 want_layout: bool,5678 want_layout: bool,
5701 want_defaults: bool,
5702 };5679 };
5703 };5680 };
57045681
...@@ -6477,7 +6454,6 @@ pub fn deinit(ip: *InternPool, gpa: Allocator, io: Io) void {...@@ -6477,7 +6454,6 @@ pub fn deinit(ip: *InternPool, gpa: Allocator, io: Io) void {
6477 ip.nav_ty_deps.deinit(gpa);6454 ip.nav_ty_deps.deinit(gpa);
6478 ip.func_ies_deps.deinit(gpa);6455 ip.func_ies_deps.deinit(gpa);
6479 ip.type_layout_deps.deinit(gpa);6456 ip.type_layout_deps.deinit(gpa);
6480 ip.struct_defaults_deps.deinit(gpa);
6481 ip.zon_file_deps.deinit(gpa);6457 ip.zon_file_deps.deinit(gpa);
6482 ip.embed_file_deps.deinit(gpa);6458 ip.embed_file_deps.deinit(gpa);
6483 ip.namespace_deps.deinit(gpa);6459 ip.namespace_deps.deinit(gpa);
...@@ -8191,7 +8167,6 @@ pub fn getDeclaredStructType(...@@ -8191,7 +8167,6 @@ pub fn getDeclaredStructType(
8191 .bits = .{8167 .bits = .{
8192 .captures_len = @enumFromInt(ini.captures.len),8168 .captures_len = @enumFromInt(ini.captures.len),
8193 .want_layout = false,8169 .want_layout = false,
8194 .want_defaults = false,
8195 },8170 },
8196 .name = undefined, // set by `finish`8171 .name = undefined, // set by `finish`
8197 .name_nav = undefined, // set by `finish`8172 .name_nav = undefined, // set by `finish`
...@@ -8256,7 +8231,6 @@ pub fn getDeclaredStructType(...@@ -8256,7 +8231,6 @@ pub fn getDeclaredStructType(
8256 .class = .no_possible_value,8231 .class = .no_possible_value,
8257 .alignment = .none,8232 .alignment = .none,
8258 .want_layout = false,8233 .want_layout = false,
8259 .want_defaults = false,
8260 },8234 },
8261 });8235 });
8262 if (ini.captures.len != 0) {8236 if (ini.captures.len != 0) {
...@@ -8337,7 +8311,6 @@ pub fn getReifiedStructType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Pe...@@ -8337,7 +8311,6 @@ pub fn getReifiedStructType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Pe
8337 .bits = .{8311 .bits = .{
8338 .captures_len = .reified,8312 .captures_len = .reified,
8339 .want_layout = false,8313 .want_layout = false,
8340 .want_defaults = false,
8341 },8314 },
8342 .name = undefined, // set by `finish`8315 .name = undefined, // set by `finish`
8343 .name_nav = undefined, // set by `finish`8316 .name_nav = undefined, // set by `finish`
...@@ -8407,7 +8380,6 @@ pub fn getReifiedStructType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Pe...@@ -8407,7 +8380,6 @@ pub fn getReifiedStructType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Pe
8407 .class = .no_possible_value,8380 .class = .no_possible_value,
8408 .alignment = .none,8381 .alignment = .none,
8409 .want_layout = false,8382 .want_layout = false,
8410 .want_defaults = false,
8411 },8383 },
8412 });8384 });
8413 _ = addExtraAssumeCapacity(extra, PackedU64.init(ini.type_hash)); // type_hash8385 _ = addExtraAssumeCapacity(extra, PackedU64.init(ini.type_hash)); // type_hash
...@@ -10647,7 +10619,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {...@@ -10647,7 +10619,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {
10647 const nav_ty_deps_len = ip.nav_ty_deps.count();10619 const nav_ty_deps_len = ip.nav_ty_deps.count();
10648 const func_ies_deps_len = ip.func_ies_deps.count();10620 const func_ies_deps_len = ip.func_ies_deps.count();
10649 const type_layout_deps_len = ip.type_layout_deps.count();10621 const type_layout_deps_len = ip.type_layout_deps.count();
10650 const struct_defaults_deps_len = ip.struct_defaults_deps.count();
10651 const zon_file_deps_len = ip.zon_file_deps.count();10622 const zon_file_deps_len = ip.zon_file_deps.count();
10652 const embed_file_deps_len = ip.embed_file_deps.count();10623 const embed_file_deps_len = ip.embed_file_deps.count();
10653 const namespace_deps_len = ip.namespace_deps.count();10624 const namespace_deps_len = ip.namespace_deps.count();
...@@ -10658,7 +10629,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {...@@ -10658,7 +10629,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {
10658 const nav_ty_deps_size = nav_ty_deps_len * 8;10629 const nav_ty_deps_size = nav_ty_deps_len * 8;
10659 const func_ies_deps_size = func_ies_deps_len * 8;10630 const func_ies_deps_size = func_ies_deps_len * 8;
10660 const type_layout_deps_size = type_layout_deps_len * 8;10631 const type_layout_deps_size = type_layout_deps_len * 8;
10661 const struct_defaults_deps_size = struct_defaults_deps_len * 8;
10662 const zon_file_deps_size = zon_file_deps_len * 8;10632 const zon_file_deps_size = zon_file_deps_len * 8;
10663 const embed_file_deps_size = embed_file_deps_len * 8;10633 const embed_file_deps_size = embed_file_deps_len * 8;
10664 const namespace_deps_size = namespace_deps_len * 8;10634 const namespace_deps_size = namespace_deps_len * 8;
...@@ -10672,7 +10642,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {...@@ -10672,7 +10642,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {
10672 \\ {d} nav_ty: {d} bytes10642 \\ {d} nav_ty: {d} bytes
10673 \\ {d} func_ies: {d} bytes10643 \\ {d} func_ies: {d} bytes
10674 \\ {d} type_layout: {d} bytes10644 \\ {d} type_layout: {d} bytes
10675 \\ {d} struct_defaults: {d} bytes
10676 \\ {d} zon_file: {d} bytes10645 \\ {d} zon_file: {d} bytes
10677 \\ {d} embed_file: {d} bytes10646 \\ {d} embed_file: {d} bytes
10678 \\ {d} namespace: {d} bytes10647 \\ {d} namespace: {d} bytes
...@@ -10680,7 +10649,7 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {...@@ -10680,7 +10649,7 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {
10680 \\10649 \\
10681 , .{10650 , .{
10682 dep_entries_size + src_hash_deps_size + nav_val_deps_size + nav_ty_deps_size +10651 dep_entries_size + src_hash_deps_size + nav_val_deps_size + nav_ty_deps_size +
10683 func_ies_deps_size + type_layout_deps_size + struct_defaults_deps_size + zon_file_deps_size +10652 func_ies_deps_size + type_layout_deps_size + zon_file_deps_size +
10684 embed_file_deps_size + namespace_deps_size + namespace_name_deps_size,10653 embed_file_deps_size + namespace_deps_size + namespace_name_deps_size,
10685 dep_entries_len,10654 dep_entries_len,
10686 dep_entries_size,10655 dep_entries_size,
...@@ -10694,8 +10663,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {...@@ -10694,8 +10663,6 @@ fn dumpDependencyStatsFallible(ip: *const InternPool, w: *Io.Writer) !void {
10694 func_ies_deps_size,10663 func_ies_deps_size,
10695 type_layout_deps_len,10664 type_layout_deps_len,
10696 type_layout_deps_size,10665 type_layout_deps_size,
10697 struct_defaults_deps_len,
10698 struct_defaults_deps_size,
10699 zon_file_deps_len,10666 zon_file_deps_len,
10700 zon_file_deps_size,10667 zon_file_deps_size,
10701 embed_file_deps_len,10668 embed_file_deps_len,
...@@ -11136,7 +11103,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator,...@@ -11136,7 +11103,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator,
11136 const info = extraData(extra_list, Tag.FuncInstance, data);11103 const info = extraData(extra_list, Tag.FuncInstance, data);
1113711104
11138 const gop = try instances.getOrPut(arena, info.generic_owner);11105 const gop = try instances.getOrPut(arena, info.generic_owner);
11139 if (!gop.found_existing) gop.value_ptr.* = .{};11106 if (!gop.found_existing) gop.value_ptr.* = .empty;
1114011107
11141 try gop.value_ptr.append(11108 try gop.value_ptr.append(
11142 arena,11109 arena,
...@@ -12969,50 +12936,6 @@ pub fn setWantTypeLayout(ip: *InternPool, io: Io, container_type: Index) bool {...@@ -12969,50 +12936,6 @@ pub fn setWantTypeLayout(ip: *InternPool, io: Io, container_type: Index) bool {
12969 }12936 }
12970}12937}
1297112938
12972/// Like `setWantTypeLayout`, but for the default field values of a struct (so this sets the
12973/// `want_defaults` flag rather than the `want_layout` flag).
12974pub fn setWantStructDefaults(ip: *InternPool, io: Io, struct_type: Index) bool {
12975 const unwrapped_index = struct_type.unwrap(ip);
12976
12977 const local = ip.getLocal(unwrapped_index.tid);
12978 local.mutate.extra.mutex.lockUncancelable(io);
12979 defer local.mutate.extra.mutex.unlock(io);
12980
12981 const extra_items = local.shared.extra.view().items(.@"0");
12982 const item = unwrapped_index.getItem(ip);
12983 switch (item.tag) {
12984 .type_struct_packed_auto,
12985 .type_struct_packed_explicit,
12986 .type_struct_packed_auto_defaults,
12987 .type_struct_packed_explicit_defaults,
12988 => {
12989 const bits: *Tag.TypeStructPacked.Bits = @ptrCast(&extra_items[
12990 item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "bits").?
12991 ]);
12992 if (bits.want_defaults) {
12993 return false;
12994 } else {
12995 bits.want_defaults = true;
12996 return true;
12997 }
12998 },
12999
13000 .type_struct => {
13001 const flags: *Tag.TypeStruct.Flags = @ptrCast(&extra_items[
13002 item.data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?
13003 ]);
13004 if (flags.want_defaults) {
13005 return false;
13006 } else {
13007 flags.want_defaults = true;
13008 return true;
13009 }
13010 },
13011
13012 else => unreachable,
13013 }
13014}
13015
13016/// Like `setWantTypeLayout`, but for runtime analysis of a function body, using the12939/// Like `setWantTypeLayout`, but for runtime analysis of a function body, using the
13017/// `FuncAnalysis.want_runtime_analysis` flag.12940/// `FuncAnalysis.want_runtime_analysis` flag.
13018pub fn setWantRuntimeFnAnalysis(ip: *InternPool, io: Io, func_index: Index) bool {12941pub fn setWantRuntimeFnAnalysis(ip: *InternPool, io: Io, func_index: Index) bool {
src/Sema.zig+29-39
...@@ -4519,10 +4519,6 @@ fn validateStructInit(...@@ -4519,10 +4519,6 @@ fn validateStructInit(
4519 if (explicit) continue;4519 if (explicit) continue;
4520 if (struct_ty.structFieldIsComptime(i, zcu)) continue;4520 if (struct_ty.structFieldIsComptime(i, zcu)) continue;
45214521
4522 if (!struct_ty.isTuple(zcu)) {
4523 try sema.ensureStructDefaultsResolved(struct_ty, init_src);
4524 }
4525
4526 const default_val = struct_ty.structFieldDefaultValue(i, zcu) orelse {4522 const default_val = struct_ty.structFieldDefaultValue(i, zcu) orelse {
4527 const field_name = struct_ty.structFieldName(i, zcu).unwrap() orelse {4523 const field_name = struct_ty.structFieldName(i, zcu).unwrap() orelse {
4528 const template = "missing tuple field with index {d}";4524 const template = "missing tuple field with index {d}";
...@@ -5180,9 +5176,9 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError...@@ -5180,9 +5176,9 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError
5180 var label: Block.Label = .{5176 var label: Block.Label = .{
5181 .zir_block = inst,5177 .zir_block = inst,
5182 .merges = .{5178 .merges = .{
5183 .src_locs = .{},5179 .src_locs = .empty,
5184 .results = .{},5180 .results = .empty,
5185 .br_list = .{},5181 .br_list = .empty,
5186 .block_inst = block_inst,5182 .block_inst = block_inst,
5187 },5183 },
5188 };5184 };
...@@ -5254,7 +5250,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -5254,7 +5250,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
5254 .parent = parent_block,5250 .parent = parent_block,
5255 .sema = sema,5251 .sema = sema,
5256 .namespace = parent_block.namespace,5252 .namespace = parent_block.namespace,
5257 .instructions = .{},5253 .instructions = .empty,
5258 .inlining = parent_block.inlining,5254 .inlining = parent_block.inlining,
5259 .comptime_reason = .{ .reason = .{5255 .comptime_reason = .{ .reason = .{
5260 .src = src,5256 .src = src,
...@@ -5389,9 +5385,9 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -5389,9 +5385,9 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro
5389 var label: Block.Label = .{5385 var label: Block.Label = .{
5390 .zir_block = inst,5386 .zir_block = inst,
5391 .merges = .{5387 .merges = .{
5392 .src_locs = .{},5388 .src_locs = .empty,
5393 .results = .{},5389 .results = .empty,
5394 .br_list = .{},5390 .br_list = .empty,
5395 .block_inst = block_inst,5391 .block_inst = block_inst,
5396 },5392 },
5397 };5393 };
...@@ -5400,7 +5396,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -5400,7 +5396,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro
5400 .parent = parent_block,5396 .parent = parent_block,
5401 .sema = sema,5397 .sema = sema,
5402 .namespace = parent_block.namespace,5398 .namespace = parent_block.namespace,
5403 .instructions = .{},5399 .instructions = .empty,
5404 .label = &label,5400 .label = &label,
5405 .inlining = parent_block.inlining,5401 .inlining = parent_block.inlining,
5406 .comptime_reason = parent_block.comptime_reason,5402 .comptime_reason = parent_block.comptime_reason,
...@@ -5839,7 +5835,6 @@ fn zirDisableInstrumentation(sema: *Sema) CompileError!void {...@@ -5839,7 +5835,6 @@ fn zirDisableInstrumentation(sema: *Sema) CompileError!void {
5839 .nav_val,5835 .nav_val,
5840 .nav_ty,5836 .nav_ty,
5841 .type_layout,5837 .type_layout,
5842 .struct_defaults,
5843 .memoized_state,5838 .memoized_state,
5844 => return, // does nothing outside a function5839 => return, // does nothing outside a function
5845 };5840 };
...@@ -5858,7 +5853,6 @@ fn zirDisableIntrinsics(sema: *Sema) CompileError!void {...@@ -5858,7 +5853,6 @@ fn zirDisableIntrinsics(sema: *Sema) CompileError!void {
5858 .nav_val,5853 .nav_val,
5859 .nav_ty,5854 .nav_ty,
5860 .type_layout,5855 .type_layout,
5861 .struct_defaults,
5862 .memoized_state,5856 .memoized_state,
5863 => return, // does nothing outside a function5857 => return, // does nothing outside a function
5864 };5858 };
...@@ -6870,7 +6864,7 @@ fn analyzeCall(...@@ -6870,7 +6864,7 @@ fn analyzeCall(
6870 .parent = null,6864 .parent = null,
6871 .sema = sema,6865 .sema = sema,
6872 .namespace = fn_nav.analysis.?.namespace,6866 .namespace = fn_nav.analysis.?.namespace,
6873 .instructions = .{},6867 .instructions = .empty,
6874 .inlining = &generic_inlining,6868 .inlining = &generic_inlining,
6875 .src_base_inst = fn_nav.analysis.?.zir_index,6869 .src_base_inst = fn_nav.analysis.?.zir_index,
6876 .type_name_ctx = fn_nav.fqn,6870 .type_name_ctx = fn_nav.fqn,
...@@ -7067,7 +7061,7 @@ fn analyzeCall(...@@ -7067,7 +7061,7 @@ fn analyzeCall(
7067 });7061 });
7068 if (func_ty_info.cc == .auto) {7062 if (func_ty_info.cc == .auto) {
7069 switch (sema.owner.unwrap()) {7063 switch (sema.owner.unwrap()) {
7070 .@"comptime", .nav_ty, .nav_val, .type_layout, .struct_defaults, .memoized_state => {},7064 .@"comptime", .nav_ty, .nav_val, .type_layout, .memoized_state => {},
7071 .func => |owner_func| ip.funcSetHasErrorTrace(io, owner_func, true),7065 .func => |owner_func| ip.funcSetHasErrorTrace(io, owner_func, true),
7072 }7066 }
7073 }7067 }
...@@ -7382,7 +7376,7 @@ fn analyzeCall(...@@ -7382,7 +7376,7 @@ fn analyzeCall(
7382 .parent = null,7376 .parent = null,
7383 .sema = sema,7377 .sema = sema,
7384 .namespace = fn_nav.analysis.?.namespace,7378 .namespace = fn_nav.analysis.?.namespace,
7385 .instructions = .{},7379 .instructions = .empty,
7386 .inlining = &inlining,7380 .inlining = &inlining,
7387 .is_typeof = block.is_typeof,7381 .is_typeof = block.is_typeof,
7388 .comptime_reason = if (block.isComptime()) .inlining_parent else null,7382 .comptime_reason = if (block.isComptime()) .inlining_parent else null,
...@@ -9945,9 +9939,9 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -9945,9 +9939,9 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
9945 var label: Block.Label = .{9939 var label: Block.Label = .{
9946 .zir_block = inst,9940 .zir_block = inst,
9947 .merges = .{9941 .merges = .{
9948 .src_locs = .{},9942 .src_locs = .empty,
9949 .results = .{},9943 .results = .empty,
9950 .br_list = .{},9944 .br_list = .empty,
9951 .block_inst = block_inst,9945 .block_inst = block_inst,
9952 },9946 },
9953 };9947 };
...@@ -10100,9 +10094,9 @@ fn zirSwitchBlock(...@@ -10100,9 +10094,9 @@ fn zirSwitchBlock(
10100 var label: Block.Label = .{10094 var label: Block.Label = .{
10101 .zir_block = inst,10095 .zir_block = inst,
10102 .merges = .{10096 .merges = .{
10103 .src_locs = .{},10097 .src_locs = .empty,
10104 .results = .{},10098 .results = .empty,
10105 .br_list = .{},10099 .br_list = .empty,
10106 .block_inst = block_inst,10100 .block_inst = block_inst,
10107 },10101 },
10108 };10102 };
...@@ -16864,7 +16858,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16864,7 +16858,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16864 .struct_type => ip.loadStructType(ty.toIntern()),16858 .struct_type => ip.loadStructType(ty.toIntern()),
16865 else => unreachable,16859 else => unreachable,
16866 };16860 };
16867 try sema.ensureStructDefaultsResolved(ty, src); // can't do this sooner, since it's not allowed on tuples
16868 struct_field_vals = try gpa.alloc(InternPool.Index, struct_type.field_types.len);16861 struct_field_vals = try gpa.alloc(InternPool.Index, struct_type.field_types.len);
1686916862
16870 for (struct_field_vals, 0..) |*field_val, field_index| {16863 for (struct_field_vals, 0..) |*field_val, field_index| {
...@@ -17122,7 +17115,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -17122,7 +17115,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
17122 .parent = block,17115 .parent = block,
17123 .sema = sema,17116 .sema = sema,
17124 .namespace = block.namespace,17117 .namespace = block.namespace,
17125 .instructions = .{},17118 .instructions = .empty,
17126 .inlining = block.inlining,17119 .inlining = block.inlining,
17127 .comptime_reason = null,17120 .comptime_reason = null,
17128 .is_typeof = true,17121 .is_typeof = true,
...@@ -17190,7 +17183,7 @@ fn zirTypeofPeer(...@@ -17190,7 +17183,7 @@ fn zirTypeofPeer(
17190 .parent = block,17183 .parent = block,
17191 .sema = sema,17184 .sema = sema,
17192 .namespace = block.namespace,17185 .namespace = block.namespace,
17193 .instructions = .{},17186 .instructions = .empty,
17194 .inlining = block.inlining,17187 .inlining = block.inlining,
17195 .comptime_reason = null,17188 .comptime_reason = null,
17196 .is_typeof = true,17189 .is_typeof = true,
...@@ -17764,9 +17757,9 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label...@@ -17764,9 +17757,9 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label
17764 .label = .{17757 .label = .{
17765 .zir_block = dest_block,17758 .zir_block = dest_block,
17766 .merges = .{17759 .merges = .{
17767 .src_locs = .{},17760 .src_locs = .empty,
17768 .results = .{},17761 .results = .empty,
17769 .br_list = .{},17762 .br_list = .empty,
17770 .block_inst = new_block_inst,17763 .block_inst = new_block_inst,
17771 },17764 },
17772 },17765 },
...@@ -17774,7 +17767,7 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label...@@ -17774,7 +17767,7 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label
17774 .parent = block,17767 .parent = block,
17775 .sema = sema,17768 .sema = sema,
17776 .namespace = block.namespace,17769 .namespace = block.namespace,
17777 .instructions = .{},17770 .instructions = .empty,
17778 .label = &labeled_block.label,17771 .label = &labeled_block.label,
17779 .inlining = block.inlining,17772 .inlining = block.inlining,
17780 .comptime_reason = block.comptime_reason,17773 .comptime_reason = block.comptime_reason,
...@@ -18753,8 +18746,6 @@ fn finishStructInit(...@@ -18753,8 +18746,6 @@ fn finishStructInit(
18753 continue;18746 continue;
18754 }18747 }
1875518748
18756 try sema.ensureStructDefaultsResolved(struct_ty, init_src);
18757
18758 const field_default: InternPool.Index = d: {18749 const field_default: InternPool.Index = d: {
18759 if (struct_type.field_defaults.len == 0) break :d .none;18750 if (struct_type.field_defaults.len == 0) break :d .none;
18760 break :d struct_type.field_defaults.get(ip)[i];18751 break :d struct_type.field_defaults.get(ip)[i];
...@@ -19420,7 +19411,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {...@@ -19420,7 +19411,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {
19420 .func => |func| if (ip.funcAnalysisUnordered(func).has_error_trace and block.ownerModule().error_tracing) {19411 .func => |func| if (ip.funcAnalysisUnordered(func).has_error_trace and block.ownerModule().error_tracing) {
19421 return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty);19412 return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty);
19422 },19413 },
19423 .@"comptime", .nav_ty, .nav_val, .type_layout, .struct_defaults, .memoized_state => {},19414 .@"comptime", .nav_ty, .nav_val, .type_layout, .memoized_state => {},
19424 }19415 }
19425 return Air.internedToRef(try pt.intern(.{ .opt = .{19416 return Air.internedToRef(try pt.intern(.{ .opt = .{
19426 .ty = opt_ptr_stack_trace_ty.toIntern(),19417 .ty = opt_ptr_stack_trace_ty.toIntern(),
...@@ -24738,7 +24729,7 @@ fn zirBuiltinExtern(...@@ -24738,7 +24729,7 @@ fn zirBuiltinExtern(
24738 // So, for now, just use our containing `declaration`.24729 // So, for now, just use our containing `declaration`.
24739 .zir_index = switch (sema.owner.unwrap()) {24730 .zir_index = switch (sema.owner.unwrap()) {
24740 .@"comptime" => |cu| ip.getComptimeUnit(cu).zir_index,24731 .@"comptime" => |cu| ip.getComptimeUnit(cu).zir_index,
24741 .type_layout, .struct_defaults => |owner_ty| Type.fromInterned(owner_ty).typeDeclInstAllowGeneratedTag(zcu).?,24732 .type_layout => |owner_ty| Type.fromInterned(owner_ty).typeDeclInstAllowGeneratedTag(zcu).?,
24742 .memoized_state => unreachable,24733 .memoized_state => unreachable,
24743 .nav_ty, .nav_val => |nav| ip.getNav(nav).analysis.?.zir_index,24734 .nav_ty, .nav_val => |nav| ip.getNav(nav).analysis.?.zir_index,
24744 .func => |func| zir_index: {24735 .func => |func| zir_index: {
...@@ -25230,7 +25221,7 @@ fn getPanicIdFunc(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.SimplePanicId) !In...@@ -25230,7 +25221,7 @@ fn getPanicIdFunc(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.SimplePanicId) !In
25230 try sema.ensureMemoizedStateResolved(src, .panic);25221 try sema.ensureMemoizedStateResolved(src, .panic);
25231 const panic_fn_index = zcu.builtin_decl_values.get(panic_id.toBuiltin());25222 const panic_fn_index = zcu.builtin_decl_values.get(panic_id.toBuiltin());
25232 switch (sema.owner.unwrap()) {25223 switch (sema.owner.unwrap()) {
25233 .@"comptime", .nav_ty, .nav_val, .type_layout, .struct_defaults, .memoized_state => {},25224 .@"comptime", .nav_ty, .nav_val, .type_layout, .memoized_state => {},
25234 .func => |owner_func| zcu.intern_pool.funcSetHasErrorTrace(io, owner_func, true),25225 .func => |owner_func| zcu.intern_pool.funcSetHasErrorTrace(io, owner_func, true),
25235 }25226 }
25236 return panic_fn_index;25227 return panic_fn_index;
...@@ -25250,7 +25241,7 @@ fn addSafetyCheck(...@@ -25250,7 +25241,7 @@ fn addSafetyCheck(
25250 .parent = parent_block,25241 .parent = parent_block,
25251 .sema = sema,25242 .sema = sema,
25252 .namespace = parent_block.namespace,25243 .namespace = parent_block.namespace,
25253 .instructions = .{},25244 .instructions = .empty,
25254 .inlining = parent_block.inlining,25245 .inlining = parent_block.inlining,
25255 .comptime_reason = null,25246 .comptime_reason = null,
25256 .src_base_inst = parent_block.src_base_inst,25247 .src_base_inst = parent_block.src_base_inst,
...@@ -25344,7 +25335,7 @@ fn addSafetyCheckUnwrapError(...@@ -25344,7 +25335,7 @@ fn addSafetyCheckUnwrapError(
25344 .parent = parent_block,25335 .parent = parent_block,
25345 .sema = sema,25336 .sema = sema,
25346 .namespace = parent_block.namespace,25337 .namespace = parent_block.namespace,
25347 .instructions = .{},25338 .instructions = .empty,
25348 .inlining = parent_block.inlining,25339 .inlining = parent_block.inlining,
25349 .comptime_reason = null,25340 .comptime_reason = null,
25350 .src_base_inst = parent_block.src_base_inst,25341 .src_base_inst = parent_block.src_base_inst,
...@@ -25449,7 +25440,7 @@ fn addSafetyCheckCall(...@@ -25449,7 +25440,7 @@ fn addSafetyCheckCall(
25449 .parent = parent_block,25440 .parent = parent_block,
25450 .sema = sema,25441 .sema = sema,
25451 .namespace = parent_block.namespace,25442 .namespace = parent_block.namespace,
25452 .instructions = .{},25443 .instructions = .empty,
25453 .inlining = parent_block.inlining,25444 .inlining = parent_block.inlining,
25454 .comptime_reason = null,25445 .comptime_reason = null,
25455 .src_base_inst = parent_block.src_base_inst,25446 .src_base_inst = parent_block.src_base_inst,
...@@ -33859,7 +33850,6 @@ const ComptimeStoreResult = @import("Sema/comptime_ptr_access.zig").ComptimeStor...@@ -33859,7 +33850,6 @@ const ComptimeStoreResult = @import("Sema/comptime_ptr_access.zig").ComptimeStor
3385933850
33860pub const type_resolution = @import("Sema/type_resolution.zig");33851pub const type_resolution = @import("Sema/type_resolution.zig");
33861pub const ensureLayoutResolved = type_resolution.ensureLayoutResolved;33852pub const ensureLayoutResolved = type_resolution.ensureLayoutResolved;
33862pub const ensureStructDefaultsResolved = type_resolution.ensureStructDefaultsResolved;
3386333853
33864pub fn getBuiltinType(sema: *Sema, src: LazySrcLoc, decl: Zcu.BuiltinDecl) SemaError!Type {33854pub fn getBuiltinType(sema: *Sema, src: LazySrcLoc, decl: Zcu.BuiltinDecl) SemaError!Type {
33865 assert(decl.kind() == .type);33855 assert(decl.kind() == .type);
src/Sema/LowerZon.zig-1
...@@ -770,7 +770,6 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool...@@ -770,7 +770,6 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool
770 const ip = &pt.zcu.intern_pool;770 const ip = &pt.zcu.intern_pool;
771771
772 try self.sema.ensureLayoutResolved(res_ty, self.import_loc);772 try self.sema.ensureLayoutResolved(res_ty, self.import_loc);
773 try self.sema.ensureStructDefaultsResolved(res_ty, self.import_loc);
774 const struct_info = self.sema.pt.zcu.typeToStruct(res_ty).?;773 const struct_info = self.sema.pt.zcu.typeToStruct(res_ty).?;
775774
776 const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.file.zoir.?)) {775 const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.file.zoir.?)) {
src/Sema/type_resolution.zig+45-144
...@@ -85,30 +85,6 @@ pub fn ensureLayoutResolved(sema: *Sema, ty: Type, src: LazySrcLoc) SemaError!vo...@@ -85,30 +85,6 @@ pub fn ensureLayoutResolved(sema: *Sema, ty: Type, src: LazySrcLoc) SemaError!vo
85 }85 }
86}86}
8787
88/// Asserts that `ty` is a non-tuple `struct` type, and ensures that its fields' default values
89/// are resolved. Adds incremental dependencies tracking the required type resolution.
90///
91/// It is not necessary to call this function to query the values of comptime fields: those values
92/// are available from type *layout* resolution, see `ensureLayoutResolved`.
93pub fn ensureStructDefaultsResolved(sema: *Sema, ty: Type, src: LazySrcLoc) SemaError!void {
94 const pt = sema.pt;
95 const zcu = pt.zcu;
96 const ip = &zcu.intern_pool;
97 assert(ip.indexToKey(ty.toIntern()) == .struct_type);
98
99 try sema.declareDependency(.{ .struct_defaults = ty.toIntern() });
100 try sema.addReferenceEntry(null, src, .wrap(.{ .struct_defaults = ty.toIntern() }));
101 if (zcu.analysis_in_progress.contains(.wrap(.{ .struct_defaults = ty.toIntern() }))) {
102 // TODO: better error message
103 return sema.failWithOwnedErrorMsg(null, try sema.errMsg(
104 ty.srcLoc(zcu),
105 "struct '{f}' depends on itself",
106 .{ty.fmt(pt)},
107 ));
108 }
109 try pt.ensureStructDefaultsUpToDate(ty);
110}
111
112/// Asserts that `struct_ty` is a non-packed non-tuple struct, and that `sema.owner` is that type.88/// Asserts that `struct_ty` is a non-packed non-tuple struct, and that `sema.owner` is that type.
113/// This function *does* register the `src_hash` dependency on the struct.89/// This function *does* register the `src_hash` dependency on the struct.
114pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {90pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {
...@@ -129,7 +105,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {...@@ -129,7 +105,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {
129 .parent = null,105 .parent = null,
130 .sema = sema,106 .sema = sema,
131 .namespace = struct_obj.namespace,107 .namespace = struct_obj.namespace,
132 .instructions = .{},108 .instructions = .empty,
133 .inlining = null,109 .inlining = null,
134 .comptime_reason = undefined, // always set before using `block`110 .comptime_reason = undefined, // always set before using `block`
135 .src_base_inst = struct_obj.zir_index,111 .src_base_inst = struct_obj.zir_index,
...@@ -168,6 +144,13 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {...@@ -168,6 +144,13 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {
168 @memset(struct_obj.field_is_comptime_bits.getAll(ip), 0);144 @memset(struct_obj.field_is_comptime_bits.getAll(ip), 0);
169145
170 const zir_struct = sema.code.getStructDecl(zir_index);146 const zir_struct = sema.code.getStructDecl(zir_index);
147
148 // If we have any default values to resolve, we'll need to map the struct decl instruction
149 // to the result type.
150 if (zir_struct.field_default_body_lens != null) {
151 try sema.inst_map.ensureSpaceForInstructions(gpa, &.{zir_index});
152 }
153
171 var field_it = zir_struct.iterateFields();154 var field_it = zir_struct.iterateFields();
172 while (field_it.next()) |zir_field| {155 while (field_it.next()) |zir_field| {
173 {156 {
...@@ -182,18 +165,16 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {...@@ -182,18 +165,16 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {
182 struct_obj.field_is_comptime_bits.getAll(ip)[bit_bag_index] |= mask;165 struct_obj.field_is_comptime_bits.getAll(ip)[bit_bag_index] |= mask;
183 }166 }
184167
185 {168 const field_ty: Type = field_ty: {
186 const field_ty_src = block.src(.{ .container_field_type = zir_field.idx });169 const field_ty_src = block.src(.{ .container_field_type = zir_field.idx });
187 const field_ty: Type = field_ty: {170 block.comptime_reason = .{ .reason = .{
188 block.comptime_reason = .{ .reason = .{171 .src = field_ty_src,
189 .src = field_ty_src,172 .r = .{ .simple = .struct_field_types },
190 .r = .{ .simple = .struct_field_types },173 } };
191 } };174 const type_ref = try sema.resolveInlineBody(&block, zir_field.type_body, zir_index);
192 const type_ref = try sema.resolveInlineBody(&block, zir_field.type_body, zir_index);175 break :field_ty try sema.analyzeAsType(&block, field_ty_src, .struct_field_types, type_ref);
193 break :field_ty try sema.analyzeAsType(&block, field_ty_src, .struct_field_types, type_ref);176 };
194 };177 struct_obj.field_types.get(ip)[zir_field.idx] = field_ty.toIntern();
195 struct_obj.field_types.get(ip)[zir_field.idx] = field_ty.toIntern();
196 }
197178
198 if (struct_obj.field_aligns.len == 0) {179 if (struct_obj.field_aligns.len == 0) {
199 assert(zir_field.align_body == null);180 assert(zir_field.align_body == null);
...@@ -210,6 +191,31 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {...@@ -210,6 +191,31 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {
210 };191 };
211 struct_obj.field_aligns.get(ip)[zir_field.idx] = field_align;192 struct_obj.field_aligns.get(ip)[zir_field.idx] = field_align;
212 }193 }
194
195 if (struct_obj.field_defaults.len == 0) {
196 assert(zir_field.default_body == null);
197 } else {
198 const field_default_src = block.src(.{ .container_field_value = zir_field.idx });
199 const field_default: InternPool.Index = d: {
200 block.comptime_reason = .{ .reason = .{
201 .src = field_default_src,
202 .r = .{ .simple = .struct_field_default_value },
203 } };
204 const default_body = zir_field.default_body orelse break :d .none;
205 // Provide the result type
206 sema.inst_map.putAssumeCapacity(zir_index, .fromType(field_ty));
207 defer assert(sema.inst_map.remove(zir_index));
208 const uncoerced_default_val = try sema.resolveInlineBody(&block, default_body, zir_index);
209 const coerced_default_val = try sema.coerce(&block, field_ty, uncoerced_default_val, field_default_src);
210 const default_val = try sema.resolveConstValue(&block, field_default_src, coerced_default_val, null);
211 if (default_val.canMutateComptimeVarState(zcu)) {
212 const field_name = struct_obj.field_names.get(ip)[zir_field.idx];
213 return sema.failWithContainsReferenceToComptimeVar(&block, field_default_src, field_name, "field default value", default_val);
214 }
215 break :d default_val.toIntern();
216 };
217 struct_obj.field_defaults.get(ip)[zir_field.idx] = field_default;
218 }
213 }219 }
214 }220 }
215221
...@@ -357,11 +363,6 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {...@@ -357,11 +363,6 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void {
357 struct_align,363 struct_align,
358 class,364 class,
359 );365 );
360
361 if (any_comptime_fields and !struct_obj.is_reified) {
362 // We also resolve field inits in this case. MLUGG TODO: this sucks, see TODO in resolveStructDefaults
363 return resolveStructDefaultsInner(sema, &block, &struct_obj);
364 }
365}366}
366367
367/// Asserts that `struct_ty` is a packed struct, and that `sema.owner` is that type.368/// Asserts that `struct_ty` is a packed struct, and that `sema.owner` is that type.
...@@ -465,105 +466,6 @@ fn resolvePackedStructLayout(...@@ -465,105 +466,6 @@ fn resolvePackedStructLayout(
465 );466 );
466}467}
467468
468/// Asserts that `struct_ty` is a non-tuple struct, and that `sema.owner` is that type.
469/// This function *does* register the `src_hash` dependency on the struct.
470pub fn resolveStructDefaults(sema: *Sema, struct_ty: Type) CompileError!void {
471 const pt = sema.pt;
472 const zcu = pt.zcu;
473 const comp = zcu.comp;
474 const gpa = comp.gpa;
475 const ip = &zcu.intern_pool;
476
477 assert(sema.owner.unwrap().struct_defaults == struct_ty.toIntern());
478
479 try sema.ensureLayoutResolved(struct_ty, struct_ty.srcLoc(zcu));
480
481 const struct_obj = ip.loadStructType(struct_ty.toIntern());
482 assert(struct_obj.want_defaults);
483
484 if (struct_obj.is_reified) {
485 // `Sema.zirReifyStruct` has already populated the default field values *and* (by loading
486 // the default values from pointers) validated their types, so we have nothing to do. We
487 // don't even need to mark any dependencies.
488 return;
489 }
490
491 try sema.declareDependency(.{ .src_hash = struct_obj.zir_index });
492
493 if (struct_obj.field_defaults.len == 0) {
494 // The struct has no default field values, so the slice has been omitted.
495 return;
496 }
497
498 for (struct_obj.field_is_comptime_bits.getAll(ip)) |bit_bag| {
499 if (bit_bag != 0) {
500 // There is a comptime field, so layout resolution already filled in the defaults for us!
501 // MLUGG TODO: perhaps a better idea would be for layout resolution to populate only the defaults *for comptime fields*.
502 return;
503 }
504 }
505
506 var block: Block = .{
507 .parent = null,
508 .sema = sema,
509 .namespace = struct_obj.namespace,
510 .instructions = .{},
511 .inlining = null,
512 .comptime_reason = undefined, // always set before using `block`
513 .src_base_inst = struct_obj.zir_index,
514 .type_name_ctx = struct_obj.name,
515 };
516 defer block.instructions.deinit(gpa);
517
518 return resolveStructDefaultsInner(sema, &block, &struct_obj);
519}
520/// MLUGG TODO: i dislike this, see the 'TODO' in the prev func
521fn resolveStructDefaultsInner(
522 sema: *Sema,
523 block: *Block,
524 struct_obj: *const InternPool.LoadedStructType,
525) CompileError!void {
526 const pt = sema.pt;
527 const zcu = pt.zcu;
528 const comp = zcu.comp;
529 const gpa = comp.gpa;
530 const ip = &zcu.intern_pool;
531
532 // We'll need to map the struct decl instruction to provide result types
533 const zir_index = struct_obj.zir_index.resolve(ip) orelse return error.AnalysisFail;
534 try sema.inst_map.ensureSpaceForInstructions(gpa, &.{zir_index});
535
536 const field_types = struct_obj.field_types.get(ip);
537
538 const zir_struct = sema.code.getStructDecl(zir_index);
539 var field_it = zir_struct.iterateFields();
540 while (field_it.next()) |zir_field| {
541 const default_val_src = block.src(.{ .container_field_value = zir_field.idx });
542 block.comptime_reason = .{ .reason = .{
543 .src = default_val_src,
544 .r = .{ .simple = .struct_field_default_value },
545 } };
546 const default_body = zir_field.default_body orelse {
547 struct_obj.field_defaults.get(ip)[zir_field.idx] = .none;
548 continue;
549 };
550 const field_ty: Type = .fromInterned(field_types[zir_field.idx]);
551 const uncoerced = ref: {
552 // Provide the result type
553 sema.inst_map.putAssumeCapacity(zir_index, .fromIntern(field_ty.toIntern()));
554 defer assert(sema.inst_map.remove(zir_index));
555 break :ref try sema.resolveInlineBody(block, default_body, zir_index);
556 };
557 const coerced = try sema.coerce(block, field_ty, uncoerced, default_val_src);
558 const default_val = try sema.resolveConstValue(block, default_val_src, coerced, null);
559 if (default_val.canMutateComptimeVarState(zcu)) {
560 const field_name = struct_obj.field_names.get(ip)[zir_field.idx];
561 return sema.failWithContainsReferenceToComptimeVar(block, default_val_src, field_name, "field default value", default_val);
562 }
563 struct_obj.field_defaults.get(ip)[zir_field.idx] = default_val.toIntern();
564 }
565}
566
567/// This logic must be kept in sync with `Type.getUnionLayout`.469/// This logic must be kept in sync with `Type.getUnionLayout`.
568pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void {470pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void {
569 const pt = sema.pt;471 const pt = sema.pt;
...@@ -583,7 +485,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void {...@@ -583,7 +485,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void {
583 .parent = null,485 .parent = null,
584 .sema = sema,486 .sema = sema,
585 .namespace = union_obj.namespace,487 .namespace = union_obj.namespace,
586 .instructions = .{},488 .instructions = .empty,
587 .inlining = null,489 .inlining = null,
588 .comptime_reason = undefined, // always set before using `block`490 .comptime_reason = undefined, // always set before using `block`
589 .src_base_inst = union_obj.zir_index,491 .src_base_inst = union_obj.zir_index,
...@@ -1048,7 +950,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void {...@@ -1048,7 +950,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void {
1048 .parent = null,950 .parent = null,
1049 .sema = sema,951 .sema = sema,
1050 .namespace = enum_obj.namespace,952 .namespace = enum_obj.namespace,
1051 .instructions = .{},953 .instructions = .empty,
1052 .inlining = null,954 .inlining = null,
1053 .comptime_reason = undefined, // always set before using `block`955 .comptime_reason = undefined, // always set before using `block`
1054 .src_base_inst = tracked_inst,956 .src_base_inst = tracked_inst,
...@@ -1287,8 +1189,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void {...@@ -1287,8 +1189,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void {
1287 }1189 }
1288 }1190 }
12891191
1290 // MLUGG TODO: fate of this line rests on whether comptime_int is a valid int tag type1192 if (enum_obj.nonexhaustive) {
1291 if (enum_obj.nonexhaustive and int_tag_ty.toIntern() != .comptime_int_type) {
1292 const fields_len = enum_obj.field_names.len;1193 const fields_len = enum_obj.field_names.len;
1293 if (fields_len >= 1 and std.math.log2_int(u64, fields_len) == int_tag_ty.bitSize(zcu)) {1194 if (fields_len >= 1 and std.math.log2_int(u64, fields_len) == int_tag_ty.bitSize(zcu)) {
1294 return sema.fail(&block, block.nodeOffset(.zero), "non-exhaustive enum specifies every value", .{});1195 return sema.fail(&block, block.nodeOffset(.zero), "non-exhaustive enum specifies every value", .{});
src/Zcu.zig+3-5
...@@ -3122,7 +3122,6 @@ pub fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void {...@@ -3122,7 +3122,6 @@ pub fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void {
3122 .nav_val => |nav| try zcu.markPoDependeeUpToDate(.{ .nav_val = nav }),3122 .nav_val => |nav| try zcu.markPoDependeeUpToDate(.{ .nav_val = nav }),
3123 .nav_ty => |nav| try zcu.markPoDependeeUpToDate(.{ .nav_ty = nav }),3123 .nav_ty => |nav| try zcu.markPoDependeeUpToDate(.{ .nav_ty = nav }),
3124 .type_layout => |ty| try zcu.markPoDependeeUpToDate(.{ .type_layout = ty }),3124 .type_layout => |ty| try zcu.markPoDependeeUpToDate(.{ .type_layout = ty }),
3125 .struct_defaults => |ty| try zcu.markPoDependeeUpToDate(.{ .struct_defaults = ty }),
3126 .func => |func| try zcu.markPoDependeeUpToDate(.{ .func_ies = func }),3125 .func => |func| try zcu.markPoDependeeUpToDate(.{ .func_ies = func }),
3127 .memoized_state => |stage| try zcu.markPoDependeeUpToDate(.{ .memoized_state = stage }),3126 .memoized_state => |stage| try zcu.markPoDependeeUpToDate(.{ .memoized_state = stage }),
3128 }3127 }
...@@ -3138,7 +3137,6 @@ fn markTransitiveDependersPotentiallyOutdated(zcu: *Zcu, maybe_outdated: AnalUni...@@ -3138,7 +3137,6 @@ fn markTransitiveDependersPotentiallyOutdated(zcu: *Zcu, maybe_outdated: AnalUni
3138 .nav_val => |nav| .{ .nav_val = nav },3137 .nav_val => |nav| .{ .nav_val = nav },
3139 .nav_ty => |nav| .{ .nav_ty = nav },3138 .nav_ty => |nav| .{ .nav_ty = nav },
3140 .type_layout => |ty| .{ .type_layout = ty },3139 .type_layout => |ty| .{ .type_layout = ty },
3141 .struct_defaults => |ty| .{ .struct_defaults = ty },
3142 .func => |func_index| .{ .func_ies = func_index },3140 .func => |func_index| .{ .func_ies = func_index },
3143 .memoized_state => |stage| .{ .memoized_state = stage },3141 .memoized_state => |stage| .{ .memoized_state = stage },
3144 };3142 };
...@@ -4116,7 +4114,7 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoArrayHashMapUnmanaged(AnalUnit, ?R...@@ -4116,7 +4114,7 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoArrayHashMapUnmanaged(AnalUnit, ?R
4116 const other: AnalUnit = .wrap(switch (unit.unwrap()) {4114 const other: AnalUnit = .wrap(switch (unit.unwrap()) {
4117 .nav_val => |n| .{ .nav_ty = n },4115 .nav_val => |n| .{ .nav_ty = n },
4118 .nav_ty => |n| .{ .nav_val = n },4116 .nav_ty => |n| .{ .nav_val = n },
4119 .@"comptime", .type_layout, .struct_defaults, .func, .memoized_state => break :queue_paired,4117 .@"comptime", .type_layout, .func, .memoized_state => break :queue_paired,
4120 });4118 });
4121 const gop = try units.getOrPut(gpa, other);4119 const gop = try units.getOrPut(gpa, other);
4122 if (gop.found_existing) break :queue_paired;4120 if (gop.found_existing) break :queue_paired;
...@@ -4273,7 +4271,7 @@ fn formatAnalUnit(data: FormatAnalUnit, writer: *Io.Writer) Io.Writer.Error!void...@@ -4273,7 +4271,7 @@ fn formatAnalUnit(data: FormatAnalUnit, writer: *Io.Writer) Io.Writer.Error!void
4273 }4271 }
4274 },4272 },
4275 .nav_val, .nav_ty => |nav, tag| return writer.print("{t}('{f}' [{}])", .{ tag, ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) }),4273 .nav_val, .nav_ty => |nav, tag| return writer.print("{t}('{f}' [{}])", .{ tag, ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) }),
4276 .type_layout, .struct_defaults => |ty, tag| return writer.print("{t}('{f}' [{}])", .{ tag, Type.fromInterned(ty).containerTypeName(ip).fmt(ip), @intFromEnum(ty) }),4274 .type_layout => |ty, tag| return writer.print("{t}('{f}' [{}])", .{ tag, Type.fromInterned(ty).containerTypeName(ip).fmt(ip), @intFromEnum(ty) }),
4277 .func => |func| {4275 .func => |func| {
4278 const nav = zcu.funcInfo(func).owner_nav;4276 const nav = zcu.funcInfo(func).owner_nav;
4279 return writer.print("func('{f}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(func) });4277 return writer.print("func('{f}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(func) });
...@@ -4299,7 +4297,7 @@ fn formatDependee(data: FormatDependee, writer: *Io.Writer) Io.Writer.Error!void...@@ -4299,7 +4297,7 @@ fn formatDependee(data: FormatDependee, writer: *Io.Writer) Io.Writer.Error!void
4299 const fqn = ip.getNav(nav).fqn;4297 const fqn = ip.getNav(nav).fqn;
4300 return writer.print("{t}('{f}')", .{ tag, fqn.fmt(ip) });4298 return writer.print("{t}('{f}')", .{ tag, fqn.fmt(ip) });
4301 },4299 },
4302 .type_layout, .struct_defaults => |ip_index, tag| {4300 .type_layout => |ip_index, tag| {
4303 const name = Type.fromInterned(ip_index).containerTypeName(ip);4301 const name = Type.fromInterned(ip_index).containerTypeName(ip);
4304 return writer.print("{t}('{f}')", .{ tag, name.fmt(ip) });4302 return writer.print("{t}('{f}')", .{ tag, name.fmt(ip) });
4305 },4303 },
src/Zcu/PerThread.zig+8-114
...@@ -865,7 +865,7 @@ fn analyzeMemoizedState(pt: Zcu.PerThread, stage: InternPool.MemoizedStateStage)...@@ -865,7 +865,7 @@ fn analyzeMemoizedState(pt: Zcu.PerThread, stage: InternPool.MemoizedStateStage)
865 .parent = null,865 .parent = null,
866 .sema = &sema,866 .sema = &sema,
867 .namespace = std_namespace,867 .namespace = std_namespace,
868 .instructions = .{},868 .instructions = .empty,
869 .inlining = null,869 .inlining = null,
870 .comptime_reason = .{ .reason = .{870 .comptime_reason = .{ .reason = .{
871 .src = src,871 .src = src,
...@@ -1014,7 +1014,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu...@@ -1014,7 +1014,7 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu
1014 .parent = null,1014 .parent = null,
1015 .sema = &sema,1015 .sema = &sema,
1016 .namespace = comptime_unit.namespace,1016 .namespace = comptime_unit.namespace,
1017 .instructions = .{},1017 .instructions = .empty,
1018 .inlining = null,1018 .inlining = null,
1019 .comptime_reason = .{ .reason = .{1019 .comptime_reason = .{ .reason = .{
1020 .src = .{1020 .src = .{
...@@ -1152,109 +1152,6 @@ pub fn ensureTypeLayoutUpToDate(pt: Zcu.PerThread, ty: Type) Zcu.SemaError!void...@@ -1152,109 +1152,6 @@ pub fn ensureTypeLayoutUpToDate(pt: Zcu.PerThread, ty: Type) Zcu.SemaError!void
1152 };1152 };
1153}1153}
11541154
1155/// Ensures that the default values of the given "declared" (not reified) `struct` type are fully
1156/// up-to-date, performing re-analysis if necessary. Asserts that `ty` is a struct (not tuple) type.
1157/// Returns `error.AnalysisFail` if an analysis error is encountered while resolving the default
1158/// field values; the caller is free to ignore this, since the error is already registered.
1159pub fn ensureStructDefaultsUpToDate(pt: Zcu.PerThread, ty: Type) Zcu.SemaError!void {
1160 const tracy = trace(@src());
1161 defer tracy.end();
1162
1163 const zcu = pt.zcu;
1164 const gpa = zcu.gpa;
1165
1166 assert(ty.zigTypeTag(zcu) == .@"struct");
1167 assert(!ty.isTuple(zcu));
1168
1169 const anal_unit: AnalUnit = .wrap(.{ .struct_defaults = ty.toIntern() });
1170
1171 log.debug("ensureStructDefaultsUpToDate {f}", .{zcu.fmtAnalUnit(anal_unit)});
1172
1173 assert(!zcu.analysis_in_progress.contains(anal_unit));
1174
1175 const was_outdated = zcu.outdated.swapRemove(anal_unit) or
1176 zcu.potentially_outdated.swapRemove(anal_unit) or
1177 zcu.intern_pool.setWantStructDefaults(zcu.comp.io, ty.toIntern());
1178
1179 if (was_outdated) {
1180 _ = zcu.outdated_ready.swapRemove(anal_unit);
1181 // `was_outdated` is true in the initial update, so this isn't a `dev.check`.
1182 if (dev.env.supports(.incremental)) {
1183 zcu.deleteUnitExports(anal_unit);
1184 zcu.deleteUnitReferences(anal_unit);
1185 zcu.deleteUnitCompileLogs(anal_unit);
1186 if (zcu.failed_analysis.fetchSwapRemove(anal_unit)) |kv| {
1187 kv.value.destroy(gpa);
1188 }
1189 _ = zcu.transitive_failed_analysis.swapRemove(anal_unit);
1190 zcu.intern_pool.removeDependenciesForDepender(gpa, anal_unit);
1191 }
1192 // For types, we already know that we have to invalidate all dependees.
1193 // TODO: we actually *could* detect whether everything was the same. should we bother?
1194 try zcu.markDependeeOutdated(.marked_po, .{ .struct_defaults = ty.toIntern() });
1195 } else {
1196 // We can trust the current information about this unit.
1197 if (zcu.failed_analysis.contains(anal_unit)) return error.AnalysisFail;
1198 if (zcu.transitive_failed_analysis.contains(anal_unit)) return error.AnalysisFail;
1199 return;
1200 }
1201
1202 if (zcu.comp.debugIncremental()) {
1203 const info = try zcu.incremental_debug_state.getUnitInfo(gpa, anal_unit);
1204 info.last_update_gen = zcu.generation;
1205 info.deps.clearRetainingCapacity();
1206 }
1207
1208 const unit_tracking = zcu.trackUnitSema(ty.containerTypeName(&zcu.intern_pool).toSlice(&zcu.intern_pool), null);
1209 defer unit_tracking.end(zcu);
1210
1211 try zcu.analysis_in_progress.put(gpa, anal_unit, {});
1212 defer assert(zcu.analysis_in_progress.swapRemove(anal_unit));
1213
1214 var analysis_arena: std.heap.ArenaAllocator = .init(gpa);
1215 defer analysis_arena.deinit();
1216
1217 var comptime_err_ret_trace: std.array_list.Managed(Zcu.LazySrcLoc) = .init(gpa);
1218 defer comptime_err_ret_trace.deinit();
1219
1220 const zir = zcu.namespacePtr(ty.getNamespaceIndex(zcu)).fileScope(zcu).zir.?;
1221
1222 var sema: Sema = .{
1223 .pt = pt,
1224 .gpa = gpa,
1225 .arena = analysis_arena.allocator(),
1226 .code = zir,
1227 .owner = anal_unit,
1228 .func_index = .none,
1229 .func_is_naked = false,
1230 .fn_ret_ty = .void,
1231 .fn_ret_ty_ies = null,
1232 .comptime_err_ret_trace = &comptime_err_ret_trace,
1233 };
1234 defer sema.deinit();
1235
1236 Sema.type_resolution.resolveStructDefaults(&sema, ty) catch |err| switch (err) {
1237 error.AnalysisFail => {
1238 if (!zcu.failed_analysis.contains(anal_unit)) {
1239 // If this unit caused the error, it would have an entry in `failed_analysis`.
1240 // Since it does not, this must be a transitive failure.
1241 try zcu.transitive_failed_analysis.put(gpa, anal_unit, {});
1242 log.debug("mark transitive analysis failure for {f}", .{zcu.fmtAnalUnit(anal_unit)});
1243 }
1244 return error.AnalysisFail;
1245 },
1246 error.OutOfMemory,
1247 error.Canceled,
1248 => |e| return e,
1249 error.ComptimeReturn => unreachable,
1250 error.ComptimeBreak => unreachable,
1251 };
1252
1253 sema.flushExports() catch |err| switch (err) {
1254 error.OutOfMemory => |e| return e,
1255 };
1256}
1257
1258/// Ensures that the resolved value of the given `Nav` is fully up-to-date, performing re-analysis1155/// Ensures that the resolved value of the given `Nav` is fully up-to-date, performing re-analysis
1259/// if necessary. Returns `error.AnalysisFail` if an analysis error is encountered; the caller is1156/// if necessary. Returns `error.AnalysisFail` if an analysis error is encountered; the caller is
1260/// free to ignore this, since the error is already registered.1157/// free to ignore this, since the error is already registered.
...@@ -1452,7 +1349,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr...@@ -1452,7 +1349,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
1452 .parent = null,1349 .parent = null,
1453 .sema = &sema,1350 .sema = &sema,
1454 .namespace = old_nav.analysis.?.namespace,1351 .namespace = old_nav.analysis.?.namespace,
1455 .instructions = .{},1352 .instructions = .empty,
1456 .inlining = null,1353 .inlining = null,
1457 .comptime_reason = undefined, // set below1354 .comptime_reason = undefined, // set below
1458 .src_base_inst = old_nav.analysis.?.zir_index,1355 .src_base_inst = old_nav.analysis.?.zir_index,
...@@ -1831,7 +1728,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr...@@ -1831,7 +1728,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr
1831 .parent = null,1728 .parent = null,
1832 .sema = &sema,1729 .sema = &sema,
1833 .namespace = old_nav.analysis.?.namespace,1730 .namespace = old_nav.analysis.?.namespace,
1834 .instructions = .{},1731 .instructions = .empty,
1835 .inlining = null,1732 .inlining = null,
1836 .comptime_reason = undefined, // set below1733 .comptime_reason = undefined, // set below
1837 .src_base_inst = old_nav.analysis.?.zir_index,1734 .src_base_inst = old_nav.analysis.?.zir_index,
...@@ -3078,7 +2975,7 @@ fn analyzeFuncBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.Sem...@@ -3078,7 +2975,7 @@ fn analyzeFuncBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.Sem
3078 .parent = null,2975 .parent = null,
3079 .sema = &sema,2976 .sema = &sema,
3080 .namespace = decl_nav.analysis.?.namespace,2977 .namespace = decl_nav.analysis.?.namespace,
3081 .instructions = .{},2978 .instructions = .empty,
3082 .inlining = null,2979 .inlining = null,
3083 .comptime_reason = null,2980 .comptime_reason = null,
3084 .src_base_inst = decl_nav.analysis.?.zir_index,2981 .src_base_inst = decl_nav.analysis.?.zir_index,
...@@ -3327,7 +3224,7 @@ pub fn processExports(pt: Zcu.PerThread) !void {...@@ -3327,7 +3224,7 @@ pub fn processExports(pt: Zcu.PerThread) !void {
3327 break :gop .{ gop.value_ptr, gop.found_existing };3224 break :gop .{ gop.value_ptr, gop.found_existing };
3328 },3225 },
3329 };3226 };
3330 if (!found_existing) value_ptr.* = .{};3227 if (!found_existing) value_ptr.* = .empty;
3331 try value_ptr.append(gpa, export_idx);3228 try value_ptr.append(gpa, export_idx);
3332 }3229 }
33333230
...@@ -3356,7 +3253,7 @@ pub fn processExports(pt: Zcu.PerThread) !void {...@@ -3356,7 +3253,7 @@ pub fn processExports(pt: Zcu.PerThread) !void {
3356 break :gop .{ gop.value_ptr, gop.found_existing };3253 break :gop .{ gop.value_ptr, gop.found_existing };
3357 },3254 },
3358 };3255 };
3359 if (!found_existing) value_ptr.* = .{};3256 if (!found_existing) value_ptr.* = .empty;
3360 try value_ptr.append(gpa, @enumFromInt(export_idx));3257 try value_ptr.append(gpa, @enumFromInt(export_idx));
3361 }3258 }
3362 }3259 }
...@@ -4353,10 +4250,7 @@ pub fn resolveTypeForCodegen(pt: Zcu.PerThread, ty: Type) Zcu.SemaError!void {...@@ -4353,10 +4250,7 @@ pub fn resolveTypeForCodegen(pt: Zcu.PerThread, ty: Type) Zcu.SemaError!void {
4353 },4250 },
43544251
4355 .@"struct" => switch (ip.indexToKey(ty.toIntern())) {4252 .@"struct" => switch (ip.indexToKey(ty.toIntern())) {
4356 .struct_type => {4253 .struct_type => try pt.ensureTypeLayoutUpToDate(ty),
4357 try pt.ensureTypeLayoutUpToDate(ty);
4358 try pt.ensureStructDefaultsUpToDate(ty);
4359 },
4360 .tuple_type => |tuple| for (0..tuple.types.len) |i| {4254 .tuple_type => |tuple| for (0..tuple.types.len) |i| {
4361 const field_is_comptime = tuple.values.get(ip)[i] != .none;4255 const field_is_comptime = tuple.values.get(ip)[i] != .none;
4362 if (field_is_comptime) continue;4256 if (field_is_comptime) continue;
src/codegen/c/Type.zig+6-6
...@@ -1054,13 +1054,13 @@ pub const Pool = struct {...@@ -1054,13 +1054,13 @@ pub const Pool = struct {
1054 };1054 };
10551055
1056 pub const empty: Pool = .{1056 pub const empty: Pool = .{
1057 .map = .{},1057 .map = .empty,
1058 .items = .{},1058 .items = .empty,
1059 .extra = .{},1059 .extra = .empty,
10601060
1061 .string_map = .{},1061 .string_map = .empty,
1062 .string_indices = .{},1062 .string_indices = .empty,
1063 .string_bytes = .{},1063 .string_bytes = .empty,
1064 };1064 };
10651065
1066 pub fn init(pool: *Pool, allocator: std.mem.Allocator) !void {1066 pub fn init(pool: *Pool, allocator: std.mem.Allocator) !void {
src/link/Elf/Object.zig+1-1
...@@ -775,7 +775,7 @@ pub fn checkDuplicates(self: *Object, dupes: anytype, elf_file: *Elf) error{OutO...@@ -775,7 +775,7 @@ pub fn checkDuplicates(self: *Object, dupes: anytype, elf_file: *Elf) error{OutO
775775
776 const gop = try dupes.getOrPut(self.symbols_resolver.items[i]);776 const gop = try dupes.getOrPut(self.symbols_resolver.items[i]);
777 if (!gop.found_existing) {777 if (!gop.found_existing) {
778 gop.value_ptr.* = .{};778 gop.value_ptr.* = .empty;
779 }779 }
780 try gop.value_ptr.append(elf_file.base.comp.gpa, self.index);780 try gop.value_ptr.append(elf_file.base.comp.gpa, self.index);
781 }781 }
src/link/Elf/ZigObject.zig+3-3
...@@ -84,7 +84,7 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -84,7 +84,7 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
84 const ptr_size = elf_file.ptrWidthBytes();84 const ptr_size = elf_file.ptrWidthBytes();
8585
86 try self.atoms.append(gpa, .{ .extra_index = try self.addAtomExtra(gpa, .{}) }); // null input section86 try self.atoms.append(gpa, .{ .extra_index = try self.addAtomExtra(gpa, .{}) }); // null input section
87 try self.relocs.append(gpa, .{}); // null relocs section87 try self.relocs.append(gpa, .empty); // null relocs section
88 try self.strtab.buffer.append(gpa, 0);88 try self.strtab.buffer.append(gpa, 0);
8989
90 {90 {
...@@ -546,7 +546,7 @@ fn newAtom(self: *ZigObject, allocator: Allocator, name_off: u32) !Atom.Index {...@@ -546,7 +546,7 @@ fn newAtom(self: *ZigObject, allocator: Allocator, name_off: u32) !Atom.Index {
546 atom_ptr.name_offset = name_off;546 atom_ptr.name_offset = name_off;
547547
548 const relocs_index: u32 = @intCast(self.relocs.items.len);548 const relocs_index: u32 = @intCast(self.relocs.items.len);
549 self.relocs.addOneAssumeCapacity().* = .{};549 self.relocs.addOneAssumeCapacity().* = .empty;
550 atom_ptr.relocs_section_index = relocs_index;550 atom_ptr.relocs_section_index = relocs_index;
551551
552 return index;552 return index;
...@@ -730,7 +730,7 @@ pub fn checkDuplicates(self: *ZigObject, dupes: anytype, elf_file: *Elf) error{O...@@ -730,7 +730,7 @@ pub fn checkDuplicates(self: *ZigObject, dupes: anytype, elf_file: *Elf) error{O
730730
731 const gop = try dupes.getOrPut(self.symbols_resolver.items[i]);731 const gop = try dupes.getOrPut(self.symbols_resolver.items[i]);
732 if (!gop.found_existing) {732 if (!gop.found_existing) {
733 gop.value_ptr.* = .{};733 gop.value_ptr.* = .empty;
734 }734 }
735 try gop.value_ptr.append(elf_file.base.comp.gpa, self.index);735 try gop.value_ptr.append(elf_file.base.comp.gpa, self.index);
736 }736 }
src/link/MachO/ZigObject.zig+2-2
...@@ -3,7 +3,7 @@ data: std.ArrayList(u8) = .empty,...@@ -3,7 +3,7 @@ data: std.ArrayList(u8) = .empty,
3basename: []const u8,3basename: []const u8,
4index: File.Index,4index: File.Index,
55
6symtab: std.MultiArrayList(Nlist) = .{},6symtab: std.MultiArrayList(Nlist) = .empty,
7strtab: StringTable = .{},7strtab: StringTable = .{},
88
9symbols: std.ArrayList(Symbol) = .empty,9symbols: std.ArrayList(Symbol) = .empty,
...@@ -29,7 +29,7 @@ uavs: UavTable = .{},...@@ -29,7 +29,7 @@ uavs: UavTable = .{},
29tlv_initializers: TlvInitializerTable = .{},29tlv_initializers: TlvInitializerTable = .{},
3030
31/// A table of relocations.31/// A table of relocations.
32relocs: RelocationTable = .{},32relocs: RelocationTable = .empty,
3333
34dwarf: ?Dwarf = null,34dwarf: ?Dwarf = null,
3535
src/link/Wasm.zig+2-2
...@@ -78,7 +78,7 @@ export_table: bool,...@@ -78,7 +78,7 @@ export_table: bool,
78/// Output name of the file78/// Output name of the file
79name: []const u8,79name: []const u8,
80/// List of relocatable files to be linked into the final binary.80/// List of relocatable files to be linked into the final binary.
81objects: std.ArrayList(Object) = .{},81objects: std.ArrayList(Object) = .empty,
8282
83func_types: std.AutoArrayHashMapUnmanaged(FunctionType, void) = .empty,83func_types: std.AutoArrayHashMapUnmanaged(FunctionType, void) = .empty,
84/// Provides a mapping of both imports and provided functions to symbol name.84/// Provides a mapping of both imports and provided functions to symbol name.
...@@ -278,7 +278,7 @@ any_tls_relocs: bool = false,...@@ -278,7 +278,7 @@ any_tls_relocs: bool = false,
278any_passive_inits: bool = false,278any_passive_inits: bool = false,
279279
280/// All MIR instructions for all Zcu functions.280/// All MIR instructions for all Zcu functions.
281mir_instructions: std.MultiArrayList(Mir.Inst) = .{},281mir_instructions: std.MultiArrayList(Mir.Inst) = .empty,
282/// Corresponds to `mir_instructions`.282/// Corresponds to `mir_instructions`.
283mir_extra: std.ArrayList(u32) = .empty,283mir_extra: std.ArrayList(u32) = .empty,
284/// All local types for all Zcu functions.284/// All local types for all Zcu functions.
src/main.zig+9-9
...@@ -979,7 +979,7 @@ fn buildOutputType(...@@ -979,7 +979,7 @@ fn buildOutputType(
979 .dirs = undefined,979 .dirs = undefined,
980 .object_format = null,980 .object_format = null,
981 .dynamic_linker = null,981 .dynamic_linker = null,
982 .modules = .{},982 .modules = .empty,
983 .opts = .{983 .opts = .{
984 .is_test = switch (arg_mode) {984 .is_test = switch (arg_mode) {
985 .zig_test, .zig_test_obj => true,985 .zig_test, .zig_test_obj => true,
...@@ -1006,18 +1006,18 @@ fn buildOutputType(...@@ -1006,18 +1006,18 @@ fn buildOutputType(
1006 .windows_libs = .empty,1006 .windows_libs = .empty,
1007 .link_inputs = .empty,1007 .link_inputs = .empty,
10081008
1009 .c_source_files = .{},1009 .c_source_files = .empty,
1010 .rc_source_files = .{},1010 .rc_source_files = .empty,
10111011
1012 .llvm_m_args = .{},1012 .llvm_m_args = .empty,
1013 .sysroot = null,1013 .sysroot = null,
1014 .lib_directories = .{}, // populated by createModule()1014 .lib_directories = .empty, // populated by createModule()
1015 .lib_dir_args = .{}, // populated from CLI arg parsing1015 .lib_dir_args = .empty, // populated from CLI arg parsing
1016 .libc_installation = null,1016 .libc_installation = null,
1017 .want_native_include_dirs = false,1017 .want_native_include_dirs = false,
1018 .frameworks = .{},1018 .frameworks = .empty,
1019 .framework_dirs = .{},1019 .framework_dirs = .empty,
1020 .rpath_list = .{},1020 .rpath_list = .empty,
1021 .each_lib_rpath = null,1021 .each_lib_rpath = null,
1022 .libc_paths_file = EnvVar.ZIG_LIBC.get(environ_map),1022 .libc_paths_file = EnvVar.ZIG_LIBC.get(environ_map),
1023 .native_system_include_paths = &.{},1023 .native_system_include_paths = &.{},