diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index b54a30ab85..f27252949b 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 8d85c60cf9..ccc38e3bba 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 a05a697526..97276339f6 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,