-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Show paths relative to the source root for diagnostics in sub-workspaces #128904
Conversation
This allows rust-analyzer to show inline errors for the library workspace. Clippy recently started doing something similar.
r? @onur-ozkan rustbot has assigned @onur-ozkan. Use |
if let Ok(prefix) = env::current_dir().unwrap().strip_prefix(&rustc_source_dir) { | ||
prefix.to_owned() | ||
} else { | ||
PathBuf::from(".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does a =.
remap even do? Wouldn't it make more sense to only add --remap-path-prefix
if strip_prefix
succeeds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a leftover from a different attempt at fixing this issue. It should indeed skip --remap-path-prefix
in this case.
This is a neat hack! I wonder, does it fundamentally rely on running inside the |
I think it fundamentally needs the wrapper to ensure that the remapping only applies to workspace members and not deps from crates.io, which have a different cwd. Also without the wrapper, you did have to be careful to pass the right
If the project has it's own RUSTC_WRAPPER, then this wrapper needs to copy the code from bootstrap's rustc wrapper. |
Sorry, I meant a wrapper script like |
☔ The latest upstream changes (presumably #122362) made this pull request unmergeable. Please resolve the merge conflicts. |
What's the plan for this PR? This lack diagnostics in It seems like rust-lang/cargo#13644 will provide an alternative to using path remapping? |
rust-lang/cargo#13644 doesn't seem to be related at all. It only adds an env var that can be read at compile time. It doesn't provide a way to actually change the working directory for spawned rustc processes. |
The PR description says
"This provides what cargo sets as the current_dir for the rustc process."
So this sounds exactly like it would change the working dir for spawned rustc processes?
|
The actual code of that PR only sets an env var. It doesn't read one. It provides the working directory of rustc to the to be compiled code as env var. |
Oh I see, I entirely misunderstood the point of that PR then, sorry.
So this is a problem even if the flag is only applied during development, not for any distributed artifacts? If |
Yes, it causes several tests to fail due to differing diagnostics as can be seen in the failing CI run. |
If there aren't any other remaps that need the other scopes |
There are other |
Sounds like it'd be good to set the remap scope not globally but separately for each remapped path. |
#132390 is a better solution than this PR. |
This allows rust-analyzer to show inline errors for the library workspace. Clippy recently started doing something similar.
Fixes #128726 which is a regression from #128534