authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-08 13:49:24+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:15+00:00
log0f3c883245f27870472978f738d6e81958e15c52
treeffd1c5a2021f606776eaa8b95645a2b3ef582608
parent3a3ac1034519d1b0c58279345e7e0f6272bccbee
signaturelock-open Commit is signed but in an unrecognized format.

Sema: always track references

I think not tracking these already causes some bugs on master with `-freference-trace=0`, but it now definitely causes bugs, because we want the reference information to decide how to write dependency loop errors. Let's begin to lean into the incremental-by-default future by disabling this small optimization---the compiler is starting to use a lot of the "incremental" logic even in non-incremental builds at this point, so the separation is becoming less and less! This particular optimization wasn't even that useful, because it's very rare for users to build with `-freference-trace=0`.

1 files changed, 0 insertions(+), 2 deletions(-)

src/Sema.zig-2
...@@ -29920,7 +29920,6 @@ pub fn addReferenceEntry(...@@ -29920,7 +29920,6 @@ pub fn addReferenceEntry(
29920 .func => |f| assert(ip.unwrapCoercedFunc(f) == f), // for `.{ .func = f }`, `f` must be uncoerced29920 .func => |f| assert(ip.unwrapCoercedFunc(f) == f), // for `.{ .func = f }`, `f` must be uncoerced
29921 else => {},29921 else => {},
29922 }29922 }
29923 if (!zcu.comp.config.incremental and zcu.comp.reference_trace == 0) return;
29924 const gop = try sema.references.getOrPut(sema.gpa, referenced_unit);29923 const gop = try sema.references.getOrPut(sema.gpa, referenced_unit);
29925 if (gop.found_existing) return;29924 if (gop.found_existing) return;
29926 try zcu.addUnitReference(sema.owner, referenced_unit, src, inline_frame: {29925 try zcu.addUnitReference(sema.owner, referenced_unit, src, inline_frame: {
...@@ -29937,7 +29936,6 @@ pub fn addTypeReferenceEntry(...@@ -29937,7 +29936,6 @@ pub fn addTypeReferenceEntry(
29937 referenced_type: Type,29936 referenced_type: Type,
29938) !void {29937) !void {
29939 const zcu = sema.pt.zcu;29938 const zcu = sema.pt.zcu;
29940 if (!zcu.comp.config.incremental and zcu.comp.reference_trace == 0) return;
29941 const gop = try sema.type_references.getOrPut(sema.gpa, referenced_type.toIntern());29939 const gop = try sema.type_references.getOrPut(sema.gpa, referenced_type.toIntern());
29942 if (gop.found_existing) return;29940 if (gop.found_existing) return;
29943 try zcu.addTypeReference(sema.owner, referenced_type.toIntern(), src);29941 try zcu.addTypeReference(sema.owner, referenced_type.toIntern(), src);