From c22660179c3f892a56ad5bacfddd4c2ec563d35e Mon Sep 17 00:00:00 2001 From: guigui64 Date: Tue, 5 May 2020 22:44:39 +0200 Subject: add the allFeatures flag (true by default) --- crates/ra_flycheck/src/lib.rs | 7 +++++-- crates/rust-analyzer/src/config.rs | 4 +++- editors/code/package.json | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index b54a30ab8..f27252949 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs @@ -24,7 +24,7 @@ pub use crate::conv::url_from_path_with_drive_lowercasing; #[derive(Clone, Debug, PartialEq, Eq)] pub enum FlycheckConfig { - CargoCommand { command: String, all_targets: bool, extra_args: Vec }, + CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec }, CustomCommand { command: String, args: Vec }, } @@ -215,7 +215,7 @@ impl FlycheckThread { self.check_process = None; let mut cmd = match &self.config { - FlycheckConfig::CargoCommand { command, all_targets, extra_args } => { + FlycheckConfig::CargoCommand { command, all_targets, all_features, extra_args } => { let mut cmd = Command::new(cargo_binary()); cmd.arg(command); cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]); @@ -223,6 +223,9 @@ impl FlycheckThread { if *all_targets { cmd.arg("--all-targets"); } + if *all_features { + cmd.arg("--all-features"); + } cmd.args(extra_args); cmd } diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 8d85c60cf..ccc38e3bb 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -89,6 +89,7 @@ impl Default for Config { check: Some(FlycheckConfig::CargoCommand { command: "check".to_string(), all_targets: true, + all_features: true, extra_args: Vec::new(), }), @@ -173,12 +174,13 @@ impl Config { } // otherwise configure command customizations _ => { - if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) + if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_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); } } }; diff --git a/editors/code/package.json b/editors/code/package.json index a05a69752..97276339f 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -296,6 +296,11 @@ "default": true, "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" }, + "rust-analyzer.checkOnSave.allFeatures": { + "type": "boolean", + "default": true, + "markdownDescription": "Check with all features (will be passed as `--all-features`)" + }, "rust-analyzer.inlayHints.typeHints": { "type": "boolean", "default": true, -- cgit v1.2.3