rust-lang / rust-lang/rust-analyzer
Setting build flags in .cargo/config.toml breaks incremental compilation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I'm working on a wasm/web_sys project, and when the rust-analyzer extension is enabled in VSCode, adding the following .cargo/config.toml file to my project causes every cargo run to rebuild the project from scratch (after blocking on "waiting for file lock on build directory" for a few seconds):
[build]
rustflags = ["--cfg=web_sys_unstable_apis"] # Enables experimental web APIs
Replacing "build" with "target.wasm32-unknown-unknown" solves the build problem, but causes rust-analyzer to emit errors when the experimental parts of web_sys are used.
rust-analyzer version: 0.0.0 (75b22326d 2022-07-03)
rustc version: 1.62.0 (a8314ef7d 2022-06-27)
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 reported setup with rust-analyzer enabled in VSCode, a .cargo/config.toml containing build.rustflags, and a wasm32-unknown-unknown target. Compare incremental cargo run behavior and rust-analyzer diagnostics with build.rustflags versus target-specific flags. Done means experimental web_sys APIs are recognized without forcing every cargo run to rebuild from scratch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100