-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
rust-analyzer version: 0.3.2593-standalone (XXXXXXXXXX 2025-08-25) [/Users/somedude/.vscode/extensions/rust-lang.rust-analyzer-0.3.2593-darwin-arm64/server/rust-analyzer]
VS Code version: Version: 1.103.2 (Universal)
In my project, I run Miri frequently and with its limitations, it's important to mark the tests that Miri can't handle with the #[cfg_attr(miri, ignore)]
attribute. Unfortunately, rust-analyzer, picks up the ignore
when it should not because the cfg_attr
is not active. When clicking on the Run Test
or Debug
link above the test and the test does not run because rust-analyzer thinks it is ignored.
Steps to Reproduce
-
Set up an test on a project. The reproduces for unit and integration tests.
-
Add the
#[cfg_attr(miri, ignore)]
attribute to a test like the following.# [test] # [cfg_attr(miri, ignore)] fn quit_test() { // --snip--snip--snip
-
Open the test in the latest Visual Studio Code and the latest rust-analyzer installed.
-
Go to the test with the Miri attribute and click the "Run test" link in the editor.
-
Rust-analyzer will run the test with the following command.
cargo test --package rl --test harness_tests -- quit_test --exact --show-output --ignored
-
This shows how the
--ignored
switch is being added even though thecfg_attr
is not applicable. -
Remove the
# [cfg_attr(miri, ignore)]
in the code. -
Click the "Run test" link.
-
The test command no longer shows the
--ignored
, and the test runs correctly.cargo test --package rl --test harness_tests -- quit_test --exact --show-output
Ideally, rust-analyzer would take into account the build configuration and discard the ignore
if the build configuration is not active.