Repository navigation
fix(rust): drop the Self keyword from type references so it stops minting a god node - #2963
rajatnagda45 wants to merge 1 commit into
Conversation
…inting a god node `_rust_collect_type_refs` treated the `Self` in `-> Self`, `&Self`, and field positions as an ordinary `type_identifier`. `Self` is a keyword alias for the enclosing impl/trait type, not a referenceable type, and it is never declared in any file -- so `ensure_named_node` minted a SOURCELESS stub whose id normalises to a single global `self` node. Every `fn new() -> Self`, builder `-> Self`, and `&Self` across the crate then rewired onto that one stub, manufacturing a false god node wired to every constructor. Skip `Self` the same way primitive types are already skipped. Real types (and associated types like `Self::Item`, which arrive as `scoped_type_identifier`) are unaffected. Adds a regression test asserting no `Self` node and no edge to the `self` stub.
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
Skips the Self keyword in _rust_collect_type_refs so it no longer mints a SOURCELESS stub that collapses into a single global self node linked to every constructor/builder. Adds test_rust_self_return_type_does_not_create_phantom_node covering -> Self and &self return types.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 104 functions depend on the 104 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract_rust()— 17 callers, 6 callees - new:
walk()— 1 callers, 8 callees
Verification — 104 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 104 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify \_rust\_collect\_type\_refs.
The verifier did not have enough to check \_rust\_collect\_type\_refs, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: not verifiable: all 200 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)
· 2 more finding(s) on lines outside this diff (see the check run).
|
Hi @safishamsi — small self-contained extractor fix here. Ran into the phantom |
What
The Rust extractor treats the
Selfkeyword in type position as an ordinary type reference, which manufactures a false god node._rust_collect_type_refsmatchesSelfas a plaintype_identifierand emits it as a referenced type. BecauseSelfis never declared in any file,ensure_named_nodemints a sourceless stub whose id normalises (viaids.normalize_id) to a single globalselfnode. Everyfn new() -> Self, builder method returning-> Self, and&Selfparameter/field across the whole crate then rewires onto that one stub — soselfbecomes a hub wired to essentially every constructor in the codebase.Selfis a keyword alias for the enclosing impl/trait type; it is not a referenceable type of its own, so no node should be emitted for it (just like theprimitive_typecase already returns early).Reproduce
Before this change
extract_rustreturns a node labelledSelfandreferencesedges pointing at the normalisedselfid. In a real multi-impl crate all of those collapse onto one global node.Fix
Skip
Selfin thetype_identifierbranch of_rust_collect_type_refs, exactly like the primitive types above it. Genuine types are untouched, and associated types such asSelf::Item(which arrive asscoped_type_identifier, resolving toItem) keep resolving as before.Tests
Adds
test_rust_self_return_type_does_not_create_phantom_nodeasserting noSelfnode and no edge targeting theselfstub, while the real type is still extracted. Full suite is green locally (only the pre-existing order-dependent flake intest_label_communities_batches_when_over_batch_size, #2877, is unrelated).