rust-analyzer: VsCode: spurious "x is never used" if Rust-analyzer > Check On Save > All Targets, is selected in rust-analyzer options
VSCode:
Version: 1.54.3
Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
Date: 2021-03-15T10:55:24.277Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.8.0-7642-generic
Rust Analyzer Version: 0.2.565
Rust Version: 1.51
If I disable Rust-analyzer > Check On Save > All Targets, the spurious warnings go away.
Cargo check also does not show any matching warnings.
It seems that when merging results between targets, especially when checking the test target and the default target, rust analyzer gets confused or doesn’t do it properly?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17 (7 by maintainers)
Okay, I’ve tracked this down to the use of mockall_double::double macro, which is an attribute macro used to rewrite imports for testing.
When run in release, it uses one impl, in test it uses another.
It basically emits in test mode:
and in debug/release:
So rust analyzer is facing two mutually exclusive module imports on test vs debug/release
I don’t know if this is ‘fixable’, I admit it’s a bit weird. But I suspect this might come up with rust_analyzer facing any mutually exclusive of cfg based features as well.