rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Running a test in VS Code does not respect `rust-analyzer.cargo.noDefaultFeatures` setting

Open jameshiew opened this issue 3 years ago • 0 comments

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer version: 0.3.1162-standalone (634cfe3d7 2022-08-07)

rustc version: (eg. output of rustc -V)

rustc 1.63.0 (4b91a6ea7 2022-08-08)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)

Visual Studio Code version details

Version: 1.70.1 Commit: 6d9b74a70ca9c7733b29f0456fd8195364076dda Date: 2022-08-10T06:09:06.916Z (2 days ago) Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Darwin x64 21.6.0


Running an individual test by clicking Run Test does not respect the rust-analyzer.cargo.noDefaultFeatures setting.

1

In this minimal reproducible example, in .vscode/settings.json, default features have been turned off and the "blue" feature has been enabled. When running the test, the command executed is:

cargo test \
    --package mre-cargo-test-default-features \
    --lib \
    --features blue \
        -- \
            tests::fails_with_default_features \
            --exact \
            --nocapture 

i.e. it is respecting the "rust-analyzer.cargo.features": ["blue"], but not "rust-analyzer.cargo.noDefaultFeatures": true, and the test fails. Interestingly the code guarded by #[cfg(feature = "red")] is greyed out before clicking Run Test.

2

jameshiew avatar Aug 12 '22 20:08 jameshiew