rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.62k stars 1.49k forks source link

VSCode Test Explorer regularly requires a full rebuild #17149

Open brandonson opened 3 weeks ago

brandonson commented 3 weeks ago

rust-analyzer version: rust-analyzer version: 0.3.1932-standalone (47a901b9b 2024-04-21)

rustc version: 1.77.2

editor or extension: VSCode Insiders with RA 0.3.1932

It's pretty common for running tests via the Test Explorer to require a full rebuild of all dependencies. Seems like build results are getting trampled and lost when check runs. That is, the common test - fix/save file - test - fix/save file loop seems to require a rebuild of everything at every step.

Seems to happen regardless of rust-analyzer.cargo.targetDir being set to true or not. However, "rust-analyzer.check.extraArgs": ["--target-dir", "rust-analyzer-check"] seems to mitigate it, but running cargo test from the CLI requires and forces a full rebuild.

HKalbasi commented 3 weeks ago

The json output format of cargo test is unstable, so we use RUSTC_BOOTSTRAP=1 to enable it. Some popular dependencies require a rebuild when this environment variable changes. As a workaround, you can set RUSTC_BOOTSTRAP=1 everywhere to avoid the rebuild, including the terminal you run cargo test and in rust-analyzer.cargo.extraEnv