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(
2992029920 .func => |f| assert(ip.unwrapCoercedFunc(f) == f), // for `.{ .func = f }`, `f` must be uncoerced
2992129921 else => {},
2992229922 }
29923 if (!zcu.comp.config.incremental and zcu.comp.reference_trace == 0) return;
2992429923 const gop = try sema.references.getOrPut(sema.gpa, referenced_unit);
2992529924 if (gop.found_existing) return;
2992629925 try zcu.addUnitReference(sema.owner, referenced_unit, src, inline_frame: {
......@@ -29937,7 +29936,6 @@ pub fn addTypeReferenceEntry(
2993729936 referenced_type: Type,
2993829937) !void {
2993929938 const zcu = sema.pt.zcu;
29940 if (!zcu.comp.config.incremental and zcu.comp.reference_trace == 0) return;
2994129939 const gop = try sema.type_references.getOrPut(sema.gpa, referenced_type.toIntern());
2994229940 if (gop.found_existing) return;
2994329941 try zcu.addTypeReference(sema.owner, referenced_type.toIntern(), src);