Files
codegraph/docs
ctype_lab a94c9dc94e fix(rust): index unit structs — bodiless is a definition, not a forward decl
`extractStruct` skips a struct with no body as a forward declaration. That
is right for C/C++ (`struct Foo;`), but Rust has no forward declarations —
`struct Unit;` is a complete unit struct. The type never entered the graph,
and neither did anything attached to it: every `impl SomeTrait for Unit`
lost its edge because the source endpoint did not exist.

Brace and tuple structs were unaffected — both carry a body field
(`field_declaration_list` / `ordered_field_declaration_list`), so only the
unit form fell through.

This is the same situation two earlier patches already handled, just a case
each of them left uncovered:

  #831  hardcoded a carve-out for C# positional records — "complete
        definitions with no body block".
  #1093 introduced `skipBodilessClass` so a bodiless CLASS is kept unless a
        language opts into skipping it.

Struct kept the unconditional skip. This adds `allowBodilessStruct`, the
per-language opt-in for the struct side, and sets it for Rust only. The
polarity is inverted relative to `skipBodilessClass` because the defaults
differ — that is documented on both flags.

The kernel's Rust walker had the same guard, placed before create_node, and
its header listed the behavior as a mirrored bug-for-bug quirk. Node
creation now happens first and the body is walked only when present, which
is how extract_interface in the same file was already shaped. Kernel↔wasm
parity is preserved (the parity suite compares the two, and passes).

Four lines of logic across four source files; the rest is comments, docs and
the two regression tests. The kernel header's quirk list, the parity suite's
docstring and the R7b port checklist all documented the old behavior as
intended, so each is updated — the checklist declares itself the living
quirk reference for the walker, so a stale entry there would misinform the
next reader.

Effect on a real Rust/TS repository (2669 nodes): 13 structs and 9
implements edges recovered.

Tests: two regression cases in extraction.test.ts. Verified failing without
the fix on the wasm path (CODEGRAPH_KERNEL=0) and passing with it, on both
the kernel and wasm paths. Full suite green — 170 files, 2922 tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 14:39:31 +09:00
..