From d3ca10d5d8bc92280a14f9e40dc41d6accc1b4c2 Mon Sep 17 00:00:00 2001 From: mlugg Date: Mon, 3 Feb 2025 20:10:44 +0000 Subject: 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. --- src/Type.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Type.zig') 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, -- cgit v1.2.3