I have some slighly odd config to make rust-analyzer work (in vscode). This ends up with rust-analyzer running cargo in a quite different way to how I run cargo via the terminal. This means each time rust-analzyer runs cargo after I have run cargo from the terminal it forces a rebuild (and visa-versa). Fix is to make rust-analyzer's cargo use a completely seperate set of build artifacts to the cargo I run from the terminal. Add this to vscode's json settings:
{
"rust-analyzer.cargo.extraEnv": {
"CARGO_PROFILE_RUST_ANALYZER_INHERITS": "dev",
},
"rust-analyzer.cargo.extraArgs": [
"--profile", "rust-analyzer"
]
}
Credit for this goes to rust-lang/rust-analyzer#6007 (comment)