]> git.lizzy.rs Git - rust.git/commitdiff
flycheck now uses the configured features
authorClemens Wasser <clemens.wasser@gmail.com>
Tue, 9 Jun 2020 19:47:54 +0000 (21:47 +0200)
committerClemens Wasser <clemens.wasser@gmail.com>
Tue, 9 Jun 2020 19:47:54 +0000 (21:47 +0200)
crates/ra_flycheck/src/lib.rs
crates/rust-analyzer/src/config.rs

index 041e38a9ff4ca4d40fc64972bf3e15fa1784d02d..6c41705298bd11f5f6cd9ea392207dabeb2f6765 100644 (file)
 
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub enum FlycheckConfig {
-    CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec<String> },
-    CustomCommand { command: String, args: Vec<String> },
+    CargoCommand {
+        command: String,
+        all_targets: bool,
+        all_features: bool,
+        features: Vec<String>,
+        extra_args: Vec<String>,
+    },
+    CustomCommand {
+        command: String,
+        args: Vec<String>,
+    },
 }
 
 /// Flycheck wraps the shared state and communication machinery used for
@@ -188,7 +197,13 @@ fn restart_check_process(&mut self) {
         self.check_process = None;
 
         let mut cmd = match &self.config {
-            FlycheckConfig::CargoCommand { command, all_targets, all_features, extra_args } => {
+            FlycheckConfig::CargoCommand {
+                command,
+                all_targets,
+                all_features,
+                extra_args,
+                features,
+            } => {
                 let mut cmd = Command::new(ra_toolchain::cargo());
                 cmd.arg(command);
                 cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
@@ -198,6 +213,9 @@ fn restart_check_process(&mut self) {
                 }
                 if *all_features {
                     cmd.arg("--all-features");
+                } else if !features.is_empty() {
+                    cmd.arg("--features");
+                    cmd.arg(features.join(" "));
                 }
                 cmd.args(extra_args);
                 cmd
index 17671f89ee415db0bef17dff04d848e75e846906..5d5f7d66a798a89bb3331e3963eed289e16a549e 100644 (file)
@@ -147,6 +147,7 @@ fn default() -> Self {
                 all_targets: true,
                 all_features: false,
                 extra_args: Vec::new(),
+                features: Vec::new(),
             }),
 
             inlay_hints: InlayHintsConfig {
@@ -234,13 +235,14 @@ pub fn update(&mut self, value: &serde_json::Value) {
                 }
                 // otherwise configure command customizations
                 _ => {
-                    if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_features })
+                    if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_features, features })
                         = &mut self.check
                     {
                         set(value, "/checkOnSave/extraArgs", extra_args);
                         set(value, "/checkOnSave/command", command);
                         set(value, "/checkOnSave/allTargets", all_targets);
                         set(value, "/checkOnSave/allFeatures", all_features);
+                        *features = self.cargo.features.clone();
                     }
                 }
             };