rust-lang / rust-lang/rust-analyzer

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

Open
#13,008 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ide C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the linked minimal example and its .vscode/settings.json, then run an individual test through VS Code's Run Test action. Compare the generated cargo test command with the configured noDefaultFeatures and features settings. Done means the command also disables default features and the test behaves accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
testing, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.