aboutsummaryrefslogtreecommitdiff
path: root/src/Zcu/PerThread.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Zcu/PerThread.zig')
-rw-r--r--src/Zcu/PerThread.zig28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig
index 21908f769f..d304ee3533 100644
--- a/src/Zcu/PerThread.zig
+++ b/src/Zcu/PerThread.zig
@@ -682,7 +682,13 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu
.namespace = comptime_unit.namespace,
.instructions = .{},
.inlining = null,
- .is_comptime = true,
+ .comptime_reason = .{ .reason = .{
+ .src = .{
+ .base_node_inst = comptime_unit.zir_index,
+ .offset = .{ .token_offset = 0 },
+ },
+ .r = .{ .simple = .comptime_keyword },
+ } },
.src_base_inst = comptime_unit.zir_index,
.type_name_ctx = try ip.getOrPutStringFmt(gpa, pt.tid, "{}.comptime", .{
Type.fromInterned(zcu.namespacePtr(comptime_unit.namespace).owner_type).containerTypeName(ip).fmt(ip),
@@ -878,7 +884,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
.namespace = old_nav.analysis.?.namespace,
.instructions = .{},
.inlining = null,
- .is_comptime = true,
+ .comptime_reason = undefined, // set below
.src_base_inst = old_nav.analysis.?.zir_index,
.type_name_ctx = old_nav.fqn,
};
@@ -893,6 +899,11 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
const section_src = block.src(.{ .node_offset_var_decl_section = 0 });
const addrspace_src = block.src(.{ .node_offset_var_decl_addrspace = 0 });
+ block.comptime_reason = .{ .reason = .{
+ .src = init_src,
+ .r = .{ .simple = .container_var_init },
+ } };
+
const maybe_ty: ?Type = if (zir_decl.type_body != null) ty: {
// Since we have a type body, the type is resolved separately!
// Of course, we need to make sure we depend on it properly.
@@ -1253,7 +1264,7 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr
.namespace = old_nav.analysis.?.namespace,
.instructions = .{},
.inlining = null,
- .is_comptime = true,
+ .comptime_reason = undefined, // set below
.src_base_inst = old_nav.analysis.?.zir_index,
.type_name_ctx = old_nav.fqn,
};
@@ -1262,6 +1273,13 @@ 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 });
+
+ block.comptime_reason = .{ .reason = .{
+ .src = ty_src,
+ .r = .{ .simple = .type },
+ } };
+
const type_body = zir_decl.type_body orelse {
// The type of this `Nav` is inferred from the value.
// In other words, this `nav_ty` depends on the corresponding `nav_val`.
@@ -1279,8 +1297,6 @@ fn analyzeNavType(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileEr
return .{ .type_changed = true };
};
- const ty_src = block.src(.{ .node_offset_var_decl_ty = 0 });
-
const resolved_ty: Type = ty: {
const uncoerced_type_ref = try sema.resolveInlineBody(&block, type_body, inst_resolved.inst);
const type_ref = try sema.coerce(&block, .type, uncoerced_type_ref, ty_src);
@@ -2442,7 +2458,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE
.namespace = decl_nav.analysis.?.namespace,
.instructions = .{},
.inlining = null,
- .is_comptime = false,
+ .comptime_reason = null,
.src_base_inst = decl_nav.analysis.?.zir_index,
.type_name_ctx = func_nav.fqn,
};