When two workspaces share a dependency, rust-analyzer is unable to find all uses of functions defined in the dependency and used in both workspaces.
This happens because the dependency is duplicated in the crate graph. When rust-analyzer goes to find in which crate the function is defined, it looks at the crate graph and just picks the first crate that matches.
Then it looks at the dependants of that crate and finds only one of the workspaces (because the crate was not deduplicated).
Deduplication was initially introduced here #14476 as an optimization and then later removed again #18080 because it broke uses of CARGO_RUSTC_CURRENT_DIR.
It looks like a difficult problem to solve. The two solutions that I can think of are these:
- Make sure that all analyses work correctly with duplicate crates in the crate graph.
- Deduplicate the crates anyway and generate the
CARGO_RUSTC_CURRENT_DIR env var only at macro expansions?
When two workspaces share a dependency, rust-analyzer is unable to find all uses of functions defined in the dependency and used in both workspaces.
This happens because the dependency is duplicated in the crate graph. When rust-analyzer goes to find in which crate the function is defined, it looks at the crate graph and just picks the first crate that matches.
Then it looks at the dependants of that crate and finds only one of the workspaces (because the crate was not deduplicated).
Deduplication was initially introduced here #14476 as an optimization and then later removed again #18080 because it broke uses of
CARGO_RUSTC_CURRENT_DIR.It looks like a difficult problem to solve. The two solutions that I can think of are these:
CARGO_RUSTC_CURRENT_DIRenv var only at macro expansions?