fix(scanner): Resolve literal Rust includes - #125
Conversation
|
Reviewed. The resolution logic is right and the subtle part is correct — include paths resolve relative to the file containing the macro, not the crate root, and I verified that transitively ( One blocker: it can fabricate an edge to a file that does not exist.
|
Record source dependencies from literal include!() calls, resolved relative to the including file. Only a single indexed in-repo .rs target is accepted; dynamic, external, non-Rust, ambiguous, and self-includes stay unresolved. Co-Authored-By: GPT-5.6 Sol <codex@openai.com>
92fa8ba to
0608490
Compare
|
Thanks — the blocker writeup was exactly right, and the fix uses the guard you suggested. Confirmed
Also changed
Optional, untouched here: the askama resolver shares the same |
JordanCoin
left a comment
There was a problem hiding this comment.
Verified fixed, both directions.
Phantom edge gone — a crate with include!("bindings.rs") where only src/bindings.rs.in exists now reports importer_count: 0 instead of asserting an importer for a file that isn't on disk. Real includes still resolve. And the exact-count guard also repairs the inverse case the old len != 1 check broke: with both bindings.rs and bindings.rs.in present, the correct edge now resolves rather than being dropped. Nice that TestResolveRustIncludeRequiresRealIndexedFile pins it.
Note the underlying index defect is still open as #130 — byExact conflating exact and extension-stripped keys is what made this reachable. Your guard is correct regardless; fixing #130 would make it belt-and-braces rather than the only thing standing between us and a phantom edge.
What does this PR do?
Record direct Rust source dependencies introduced by literal
include!calls. Paths are decoded with the existing Rust literal parser, resolved relative to the including file, and accepted only when the path itself is indexed exactly once (abindings.rs.intemplate must not fabricate abindings.rstarget). Dynamic, missing, external, non-Rust, ambiguous, and self targets remain unresolved.Type of change
Checklist
go build && ./codemap .CONTRIBUTING.md; this does not add a new language.Additional notes
Maintainer review addressed: the resolver requires the indexed file itself, so a gitignored, build-time-generated
bindings.rsbesidebindings.rs.inno longer fabricates an edge, and a real file keeps its edge when a template shares its key. Extraction and conservative-resolution tests,go vet ./..., the full suite, and the scanner race suite are GREEN on macOS Go 1.26.5.Worktrunk's alternate
git-wtbinary usesinclude!("main.rs"); this change adds the missingsrc/git_wt.rstosrc/main.rsdependency edge. The inspected GitButler, Codanna, and Worktrunk corpora contain no other literal source includes, so this is intentionally presented as a narrow correctness fix.include_str!andinclude_bytes!are not matched; resolving their non-Rust assets remains a documented follow-up.This branch targets main and contains no generic proc-macro, Cargo-topology, configuration, or non-Rust changes.
Developed with carefully directed, manually reviewed AI assistance.