Repository navigation
fix(rust): expand grouped use imports - #2932
Conversation
Signed-off-by: kasheeesh08 <[email protected]>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Signed-off-by: kasheeesh08 <[email protected]>
Signed-off-by: Martin Vogel <[email protected]>
|
Thank you so much, @kasheeesh08, and welcome! We reviewed this carefully and it is ready to merge: walking the use tree through the grammar's own fields handles every form we tried (nested groups, Another change that just merged also edits tests/test_pipeline.c (different tests, no conflict), so we merged current main into your branch - a plain signed-off merge commit, your change is untouched - to get a fresh CI run on the exact tree that will merge. Nothing is needed from you: it merges as soon as that run is green. If you push again, please pull first so the merge commit is kept. |
|
Thank you so much, @kasheeesh08, for this fix, and welcome to the project! Walking the use tree through the grammar's own fields (argument, path, list, alias) instead of slicing the declaration text is exactly the right approach, and it handles every form we tried: nested groups, We also measured the change on two real Rust workspaces, jdx/mise (the project from the issue) and meilisearch. Every grouped import now binds its own name: on mise the 1,912 import edges whose local name started with Merged in d40ebf6. Thanks again for the careful work! |
In a Cargo workspace a relative `use` bound a sibling crate's item. The import resolver has no Rust branch, so `crate::util::helper` fell through to the project-wide symbol-name fallback (Strategy 3), which matches the last path segment, then every enclosing segment, against every same-named definition in the project and keeps the lexicographically smallest QN: whichever crate sorts first. The same fallback bound imports of external crates to project symbols by name (`use serde_json::json` -> the project's own `json` function, and every `json!` call through import_map) and let a module segment bind a function (`crate::util::Gone` -> fn `util`), while Strategy 4 resolved `crate::`, `self::` and `super::` from the repository root instead of the crate's module root. A Rust import of a file under a Cargo.toml is now classified by its first path segment and resolved inside exactly one crate: - `crate::` is the importing crate's module root: the nearest Cargo.toml's src/ (or tests/, benches/, examples/; a build script is its own root); - `self::` / `super::` are relative to the importing file's module path; - a child module of the importing module is that module (2018 paths); - a workspace member's crate name (a package `foo-bar` is `foo_bar`) is that member; - anything else (std, core, a dependency) binds no project symbol. Inside the crate the item at the module the path names wins, else the module the full path names, else a same-named item in a submodule of that module (a re-export from below), else the type an associated item or enum variant belongs to. Nothing else is guessed, ties break on module-path fit then QN, and files with no Cargo.toml above them keep the generic strategies. The CALLS import map is built from these IMPORTS edges in both drivers, so import_map CALLS follow. On jdx/mise this removes all 720 relative IMPORTS that crossed into another workspace crate, all 1,123 IMPORTS bound through an external-crate path and all 259 import_map CALLS that followed them; IMPORTS and import_map CALLS into a crate the caller does not depend on drop from 920 and 12 to 0. Wall time and index worker peak RSS are unchanged; a non-Rust control graph is byte-identical. Strategy 4's module-prefix loop moves into resolve_module_prefixes so the crate tree can reuse its lookup (plus the mod.rs form); Strategy 4's own behaviour is unchanged. Refs DeusData#2922, DeusData#2932 Signed-off-by: Martin Vogel <[email protected]>
Fixes #2922
Summary
Fixes Rust grouped
useimport extraction so grouped imports are expanded into individual import paths.The extractor now handles nested grouped imports, aliases,
self, and wildcard imports recursively.Changes
CBMImportrecords.self, and wildcard imports.Testing
Local test execution was blocked by Windows sandbox environment restrictions. No local test results are claimed.
GitHub Actions CI is expected to provide authoritative test and lint verification.