diff options
| author | Shoyu Vanilla (Flint) <modulo641@gmail.com> | 2025-07-21 14:27:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-21 14:27:12 +0000 |
| commit | 87aa056206fa883963cfa483df5e8e69e0393086 (patch) | |
| tree | ac3ce53c12f24e1530f5122cabeeb036eb6ae761 | |
| parent | 8f67bcf4b0524b2efcbeeae50d393b1b51474237 (diff) | |
| parent | f862bcc7f656a5030771b9297ef54c14f77e81bb (diff) | |
| download | rust-87aa056206fa883963cfa483df5e8e69e0393086.tar.gz rust-87aa056206fa883963cfa483df5e8e69e0393086.zip | |
Merge pull request #20271 from ChayimFriedman2/cfg-settest-flycheck
fix: Disable tests in flycheck if `cfg.setTest` is set to false
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs | 2 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 51d4c29aa74..9456fd8809b 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -2162,6 +2162,7 @@ impl Config { extra_test_bin_args: self.runnables_extraTestBinaryArgs(source_root).clone(), extra_env: self.extra_env(source_root).clone(), target_dir: self.target_dir_from_config(source_root), + set_test: true, } } @@ -2219,6 +2220,7 @@ impl Config { extra_test_bin_args: self.runnables_extraTestBinaryArgs(source_root).clone(), extra_env: self.check_extra_env(source_root), target_dir: self.target_dir_from_config(source_root), + set_test: *self.cfg_setTest(source_root), }, ansi_color_output: self.color_diagnostic_output(), }, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs index 91d37bd7c9e..bec57a4bede 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs @@ -31,6 +31,7 @@ pub(crate) enum InvocationStrategy { pub(crate) struct CargoOptions { pub(crate) target_tuples: Vec<String>, pub(crate) all_targets: bool, + pub(crate) set_test: bool, pub(crate) no_default_features: bool, pub(crate) all_features: bool, pub(crate) features: Vec<String>, @@ -54,7 +55,13 @@ impl CargoOptions { cmd.args(["--target", target.as_str()]); } if self.all_targets { - cmd.arg("--all-targets"); + if self.set_test { + cmd.arg("--all-targets"); + } else { + // No --benches unfortunately, as this implies --tests (see https://github.com/rust-lang/cargo/issues/6454), + // and users setting `cfg.seTest = false` probably prefer disabling benches than enabling tests. + cmd.args(["--lib", "--bins", "--examples"]); + } } if self.all_features { cmd.arg("--all-features"); |
