-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workspace crate graph duplication breaks "find all references" #18804
Comments
Isn't really feasible, if the crates are duplicated they are inherently different and they themselves as well as their definitions can't be treated the same.
Isn't an option as cargo is likely to introduce an env var that can be observed outside of proc-macros. Quoting myself from #18080
I don't recall which one it was though. Would be good to double check which one that was but I reckon its not the only reason why we can't do so. |
I assume this means no matter from which workspace usage you trigger the search, you always only find usages in the first workspace (and not the one you triggered it from)? |
Yes that is exactly what happens |
I think it is unlikely for dependencies to ever use Btw, |
I can not reproduce #17748 even if I remove these lines rust-analyzer/crates/project-model/src/env.rs Lines 67 to 69 in add0963
|
Yeah I think the So my proposal is to add back deduplication and remove the I have the changes locally, so I can just make a PR |
Well thats nice to hear that they are likely rolling back In that case, yes, we can consider bringing the dedup logic back. (though I think my PR also cleaned up some stuff in general, so a full backout of that PR is probably not what we want). This topic did raise another thing to keep in mind though, cargo configs that specifiy relative env vars will thrash the dedup logic as well. (as that is effectively what that env var was as well) Now this is a user opt-in, so we could probably diagnose and warn when this happens. |
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_DIR
env var only at macro expansions?The text was updated successfully, but these errors were encountered: