From a20b8d751bb59becb19c9edbb5e3f3ffe31bbcf3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 21 Jul 2020 10:30:54 +0200 Subject: Propagate cargo.target to checkOnSave --- crates/flycheck/src/lib.rs | 6 ++++++ crates/rust-analyzer/src/config.rs | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 6804d9bda..6e06adaa5 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -22,6 +22,7 @@ pub use cargo_metadata::diagnostic::{ pub enum FlycheckConfig { CargoCommand { command: String, + target_tripple: Option, all_targets: bool, all_features: bool, features: Vec, @@ -178,6 +179,7 @@ impl FlycheckActor { let mut cmd = match &self.config { FlycheckConfig::CargoCommand { command, + target_tripple, all_targets, all_features, extra_args, @@ -187,6 +189,10 @@ impl FlycheckActor { cmd.arg(command); cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) .arg(self.workspace_root.join("Cargo.toml")); + + if let Some(target) = target_tripple { + cmd.args(&["--target", target.as_str()]); + } if *all_targets { cmd.arg("--all-targets"); } diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 68b2a2abd..11086360b 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -148,6 +148,7 @@ impl Config { rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() }, flycheck: Some(FlycheckConfig::CargoCommand { command: "check".to_string(), + target_tripple: None, all_targets: true, all_features: false, extra_args: Vec::new(), @@ -198,7 +199,7 @@ impl Config { all_features: data.cargo_allFeatures, features: data.cargo_features.clone(), load_out_dirs_from_check: data.cargo_loadOutDirsFromCheck, - target: data.cargo_target, + target: data.cargo_target.clone(), }; self.proc_macro_srv = if data.procMacro_enable { @@ -223,6 +224,7 @@ impl Config { } Some(_) | None => FlycheckConfig::CargoCommand { command: data.checkOnSave_command, + target_tripple: data.checkOnSave_target.or(data.cargo_target), all_targets: data.checkOnSave_allTargets, all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), features: data.checkOnSave_features.unwrap_or(data.cargo_features), @@ -384,10 +386,11 @@ config_data! { cargo_noDefaultFeatures: bool = false, cargo_target: Option = None, + checkOnSave_enable: bool = false, checkOnSave_allFeatures: Option = None, checkOnSave_allTargets: bool = true, checkOnSave_command: String = "check".into(), - checkOnSave_enable: bool = false, + checkOnSave_target: Option = None, checkOnSave_extraArgs: Vec = Vec::new(), checkOnSave_features: Option> = None, checkOnSave_overrideCommand: Option> = None, -- cgit v1.2.3