Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/config.rs2
-rw-r--r--crates/rust-analyzer/src/flycheck.rs9
2 files changed, 10 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 51d4c29aa7..9456fd8809 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/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/crates/rust-analyzer/src/flycheck.rs b/crates/rust-analyzer/src/flycheck.rs
index 91d37bd7c9..bec57a4bed 100644
--- a/crates/rust-analyzer/src/flycheck.rs
+++ b/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");