diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-02-03 20:10:44 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-02-04 16:20:29 +0000 |
| commit | d3ca10d5d8bc92280a14f9e40dc41d6accc1b4c2 (patch) | |
| tree | 20306667045b1136e12399d5fe13612925f0677c /src/Type.zig | |
| parent | 3a4bb47fedbb890dc149622e31c75101b14c3b16 (diff) | |
| download | zig-d3ca10d5d8bc92280a14f9e40dc41d6accc1b4c2.tar.gz zig-d3ca10d5d8bc92280a14f9e40dc41d6accc1b4c2.zip | |
Zcu: remove `*_loaded` fields on `File`
Instead, `source`, `tree`, and `zir` should all be optional. This is
precisely what we're actually trying to model here; and `File` isn't
optimized for memory consumption or serializability anyway, so it's fine
to use a couple of extra bytes on actual optionals here.
Diffstat (limited to 'src/Type.zig')
| -rw-r--r-- | src/Type.zig | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Type.zig b/src/Type.zig index 0fd6e184d8..690cc3fea0 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -3587,8 +3587,7 @@ pub fn typeDeclSrcLine(ty: Type, zcu: *Zcu) ?u32 { }; const info = tracked.resolveFull(&zcu.intern_pool) orelse return null; const file = zcu.fileByIndex(info.file); - assert(file.zir_loaded); - const zir = file.zir; + const zir = file.zir.?; const inst = zir.instructions.get(@intFromEnum(info.inst)); return switch (inst.tag) { .struct_init, .struct_init_ref => zir.extraData(Zir.Inst.StructInit, inst.data.pl_node.payload_index).data.abs_line, @@ -3905,7 +3904,7 @@ fn resolveStructInner( var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa); defer comptime_err_ret_trace.deinit(); - const zir = zcu.namespacePtr(struct_obj.namespace).fileScope(zcu).zir; + const zir = zcu.namespacePtr(struct_obj.namespace).fileScope(zcu).zir.?; var sema: Sema = .{ .pt = pt, .gpa = gpa, @@ -3959,7 +3958,7 @@ fn resolveUnionInner( var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa); defer comptime_err_ret_trace.deinit(); - const zir = zcu.namespacePtr(union_obj.namespace).fileScope(zcu).zir; + const zir = zcu.namespacePtr(union_obj.namespace).fileScope(zcu).zir.?; var sema: Sema = .{ .pt = pt, .gpa = gpa, |
