rust-lang / rust-lang/rust-analyzer
Setting ra.cargo.target setting disables errors in some configuration
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Originally reported this as https://github.com/fannheyward/coc-rust-analyzer/issues/854 but installed and reproduced in VSCode as well.
Enabling configuration
"rust-analyzer.cargo.target": "wasm32-unknown-unknown"
results in errors in the project become hidden. Steps in VSCode:
- Open project which has errors (
cargo check,cargo check --target wasm32-unknown-unknownboth report them) - Edit settings.json (add ra.cargo.target)
- "Reload Now"
- Errors disappear
- Edit setings.json (remove ra.cargo.target)
- "Reload Now"
- Errors appear back
This does not reproduce on a minimal project:
cargo new example- Edit the default hello world to have invalid fmt string
I can't understand why my non-oss project does exhibit this behaviour, checked so far that this is not caused by the following (tested them on the cargo new example):
$project/.cargo/configwithwasm32-unknown-unknownspecific RUSTFLAGS- having a target (wasm32-unknown-unknown) specific dependency
lib.crate-type = ["cdylib", "rlib"]- patched dependency
rust-analyzer version used in VSCode: 996300f4a 2021-08-23 stable.
For the troubleshooting guide points:
- in vscode there are no errors about project structure
- there is no crash to investigate
- comparing verbose server trace between "ra.cargo.target" enabled and not the only difference between seems to be that one has the errors reported as expected and other one doesn't
Could you offer more tips to narrow this down to a minimal example? Errors in my non-oss project are type check errors related to types/assumptions coming from external crates. Perhaps the format string error is bad substitute for these. I will see if I can figure out a minimal example with misuse of external crate.
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 reproducing the behavior in VSCode using the reported rust-analyzer.cargo.target setting and the non-minimal project; compare it with the cargo new example. Review the verbose server trace with the setting enabled and disabled, then narrow the reproduction around external-crate type-check errors. Done means project errors remain visible when the target setting is enabled and a regression test covers the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100