diff options
author | Aleksey Kladov <[email protected]> | 2020-07-21 09:30:54 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-21 09:30:54 +0100 |
commit | a20b8d751bb59becb19c9edbb5e3f3ffe31bbcf3 (patch) | |
tree | 55be1108d5e71b6bf9a233a32cfef907007d60b2 /crates | |
parent | 3432afcbd2fa69fe7da02506123a32baba083f7a (diff) |
Propagate cargo.target to checkOnSave
Diffstat (limited to 'crates')
-rw-r--r-- | crates/flycheck/src/lib.rs | 6 | ||||
-rw-r--r-- | 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::{ | |||
22 | pub enum FlycheckConfig { | 22 | pub enum FlycheckConfig { |
23 | CargoCommand { | 23 | CargoCommand { |
24 | command: String, | 24 | command: String, |
25 | target_tripple: Option<String>, | ||
25 | all_targets: bool, | 26 | all_targets: bool, |
26 | all_features: bool, | 27 | all_features: bool, |
27 | features: Vec<String>, | 28 | features: Vec<String>, |
@@ -178,6 +179,7 @@ impl FlycheckActor { | |||
178 | let mut cmd = match &self.config { | 179 | let mut cmd = match &self.config { |
179 | FlycheckConfig::CargoCommand { | 180 | FlycheckConfig::CargoCommand { |
180 | command, | 181 | command, |
182 | target_tripple, | ||
181 | all_targets, | 183 | all_targets, |
182 | all_features, | 184 | all_features, |
183 | extra_args, | 185 | extra_args, |
@@ -187,6 +189,10 @@ impl FlycheckActor { | |||
187 | cmd.arg(command); | 189 | cmd.arg(command); |
188 | cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) | 190 | cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) |
189 | .arg(self.workspace_root.join("Cargo.toml")); | 191 | .arg(self.workspace_root.join("Cargo.toml")); |
192 | |||
193 | if let Some(target) = target_tripple { | ||
194 | cmd.args(&["--target", target.as_str()]); | ||
195 | } | ||
190 | if *all_targets { | 196 | if *all_targets { |
191 | cmd.arg("--all-targets"); | 197 | cmd.arg("--all-targets"); |
192 | } | 198 | } |
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 { | |||
148 | rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() }, | 148 | rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() }, |
149 | flycheck: Some(FlycheckConfig::CargoCommand { | 149 | flycheck: Some(FlycheckConfig::CargoCommand { |
150 | command: "check".to_string(), | 150 | command: "check".to_string(), |
151 | target_tripple: None, | ||
151 | all_targets: true, | 152 | all_targets: true, |
152 | all_features: false, | 153 | all_features: false, |
153 | extra_args: Vec::new(), | 154 | extra_args: Vec::new(), |
@@ -198,7 +199,7 @@ impl Config { | |||
198 | all_features: data.cargo_allFeatures, | 199 | all_features: data.cargo_allFeatures, |
199 | features: data.cargo_features.clone(), | 200 | features: data.cargo_features.clone(), |
200 | load_out_dirs_from_check: data.cargo_loadOutDirsFromCheck, | 201 | load_out_dirs_from_check: data.cargo_loadOutDirsFromCheck, |
201 | target: data.cargo_target, | 202 | target: data.cargo_target.clone(), |
202 | }; | 203 | }; |
203 | 204 | ||
204 | self.proc_macro_srv = if data.procMacro_enable { | 205 | self.proc_macro_srv = if data.procMacro_enable { |
@@ -223,6 +224,7 @@ impl Config { | |||
223 | } | 224 | } |
224 | Some(_) | None => FlycheckConfig::CargoCommand { | 225 | Some(_) | None => FlycheckConfig::CargoCommand { |
225 | command: data.checkOnSave_command, | 226 | command: data.checkOnSave_command, |
227 | target_tripple: data.checkOnSave_target.or(data.cargo_target), | ||
226 | all_targets: data.checkOnSave_allTargets, | 228 | all_targets: data.checkOnSave_allTargets, |
227 | all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), | 229 | all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), |
228 | features: data.checkOnSave_features.unwrap_or(data.cargo_features), | 230 | features: data.checkOnSave_features.unwrap_or(data.cargo_features), |
@@ -384,10 +386,11 @@ config_data! { | |||
384 | cargo_noDefaultFeatures: bool = false, | 386 | cargo_noDefaultFeatures: bool = false, |
385 | cargo_target: Option<String> = None, | 387 | cargo_target: Option<String> = None, |
386 | 388 | ||
389 | checkOnSave_enable: bool = false, | ||
387 | checkOnSave_allFeatures: Option<bool> = None, | 390 | checkOnSave_allFeatures: Option<bool> = None, |
388 | checkOnSave_allTargets: bool = true, | 391 | checkOnSave_allTargets: bool = true, |
389 | checkOnSave_command: String = "check".into(), | 392 | checkOnSave_command: String = "check".into(), |
390 | checkOnSave_enable: bool = false, | 393 | checkOnSave_target: Option<String> = None, |
391 | checkOnSave_extraArgs: Vec<String> = Vec::new(), | 394 | checkOnSave_extraArgs: Vec<String> = Vec::new(), |
392 | checkOnSave_features: Option<Vec<String>> = None, | 395 | checkOnSave_features: Option<Vec<String>> = None, |
393 | checkOnSave_overrideCommand: Option<Vec<String>> = None, | 396 | checkOnSave_overrideCommand: Option<Vec<String>> = None, |