rust-lang / rust-lang/rust-analyzer
RA shows warnings in autogenerated files inside target directory when using alternative target location
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: 0.0.0 (cc0bb71e2 2022-07-02)
rustc version: rustc 1.64.0-nightly (46b8c23f3 2022-07-01)
relevant settings:
{
"rust-analyzer.server.extraEnv": {
"CARGO_TARGET_DIR": "target-ra"
},
"rust-analyzer.checkOnSave.command": "clippy"
}
I use target-ra as a separate target directory for RA in VSCode. My project uses lalrpop which puts generated files in this target directory. RA shows warnings in one of these autogenerated files (target-ra/debug/build/fml-738faf2a1534b33c/out/fml.rs). I think this is a bug because it doesn't show warnings if using the normal shared target directory and in general it makes no sense to show warns in files i can't do anything about.
It can be reproduced on this repo on the ra-bug branch. It contains a .vscode config that should contain everything needed - the warnings should be visible as soon as RA finishes analyzing the project:

Interestingly, there are other target-ra/debug/build/fml-*/out/fml.rs files but it only happens with this particular one.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by checking the .vscode configuration in the linked repository's ra-bug branch and reproducing the diagnostics in target-ra/debug/build/fml-738faf2a1534b33c/out/fml.rs. Then trace how rust-analyzer handles generated files under an alternative CARGO_TARGET_DIR. Done means warnings from autogenerated target files are suppressed without hiding relevant diagnostics from project source files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100