Skip to content

Workspace crate graph duplication breaks "find all references" #18804

@LHolten

Description

@LHolten

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-idegeneral IDE featuresA-project-modelproject model and workspace related issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions