aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClemens Wasser <[email protected]>2020-07-30 15:04:01 +0100
committerClemens Wasser <[email protected]>2020-07-30 15:04:01 +0100
commit8d9f8ac2739e7d02bcbc69e933682c2ef305f987 (patch)
tree4ceced247e8959e6b385b90e6a561fac6b81470d
parent96c3ff1c573f97e5089fc0ba01ede6fe43693668 (diff)
flycheck: Added checkOnSave.noDefaultFeatures
This commit adds the option `rust-analyzer.checkOnSave.noDefaultFeatures` and fixes #5550.
-rw-r--r--crates/flycheck/src/lib.rs13
-rw-r--r--crates/rust-analyzer/src/config.rs5
-rw-r--r--editors/code/package.json8
3 files changed, 23 insertions, 3 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index ad376ad18..7c38f5ef9 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -24,6 +24,7 @@ pub enum FlycheckConfig {
24 command: String, 24 command: String,
25 target_triple: Option<String>, 25 target_triple: Option<String>,
26 all_targets: bool, 26 all_targets: bool,
27 no_default_features: bool,
27 all_features: bool, 28 all_features: bool,
28 features: Vec<String>, 29 features: Vec<String>,
29 extra_args: Vec<String>, 30 extra_args: Vec<String>,
@@ -180,6 +181,7 @@ impl FlycheckActor {
180 FlycheckConfig::CargoCommand { 181 FlycheckConfig::CargoCommand {
181 command, 182 command,
182 target_triple, 183 target_triple,
184 no_default_features,
183 all_targets, 185 all_targets,
184 all_features, 186 all_features,
185 extra_args, 187 extra_args,
@@ -198,9 +200,14 @@ impl FlycheckActor {
198 } 200 }
199 if *all_features { 201 if *all_features {
200 cmd.arg("--all-features"); 202 cmd.arg("--all-features");
201 } else if !features.is_empty() { 203 } else {
202 cmd.arg("--features"); 204 if *no_default_features {
203 cmd.arg(features.join(" ")); 205 cmd.arg("--no-default-features");
206 }
207 if !features.is_empty() {
208 cmd.arg("--features");
209 cmd.arg(features.join(" "));
210 }
204 } 211 }
205 cmd.args(extra_args); 212 cmd.args(extra_args);
206 cmd 213 cmd
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index e11c8b909..70b4512d0 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -151,6 +151,7 @@ impl Config {
151 flycheck: Some(FlycheckConfig::CargoCommand { 151 flycheck: Some(FlycheckConfig::CargoCommand {
152 command: "check".to_string(), 152 command: "check".to_string(),
153 target_triple: None, 153 target_triple: None,
154 no_default_features: false,
154 all_targets: true, 155 all_targets: true,
155 all_features: false, 156 all_features: false,
156 extra_args: Vec::new(), 157 extra_args: Vec::new(),
@@ -234,6 +235,9 @@ impl Config {
234 command: data.checkOnSave_command, 235 command: data.checkOnSave_command,
235 target_triple: data.checkOnSave_target.or(data.cargo_target), 236 target_triple: data.checkOnSave_target.or(data.cargo_target),
236 all_targets: data.checkOnSave_allTargets, 237 all_targets: data.checkOnSave_allTargets,
238 no_default_features: data
239 .checkOnSave_noDefaultFeatures
240 .unwrap_or(data.cargo_noDefaultFeatures),
237 all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), 241 all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures),
238 features: data.checkOnSave_features.unwrap_or(data.cargo_features), 242 features: data.checkOnSave_features.unwrap_or(data.cargo_features),
239 extra_args: data.checkOnSave_extraArgs, 243 extra_args: data.checkOnSave_extraArgs,
@@ -398,6 +402,7 @@ config_data! {
398 checkOnSave_allFeatures: Option<bool> = None, 402 checkOnSave_allFeatures: Option<bool> = None,
399 checkOnSave_allTargets: bool = true, 403 checkOnSave_allTargets: bool = true,
400 checkOnSave_command: String = "check".into(), 404 checkOnSave_command: String = "check".into(),
405 checkOnSave_noDefaultFeatures: Option<bool> = None,
401 checkOnSave_target: Option<String> = None, 406 checkOnSave_target: Option<String> = None,
402 checkOnSave_extraArgs: Vec<String> = Vec::new(), 407 checkOnSave_extraArgs: Vec<String> = Vec::new(),
403 checkOnSave_features: Option<Vec<String>> = None, 408 checkOnSave_features: Option<Vec<String>> = None,
diff --git a/editors/code/package.json b/editors/code/package.json
index 658c913fd..1adf055d0 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -323,6 +323,14 @@
323 "default": true, 323 "default": true,
324 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" 324 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
325 }, 325 },
326 "rust-analyzer.checkOnSave.noDefaultFeatures": {
327 "type": [
328 "null",
329 "boolean"
330 ],
331 "default": null,
332 "markdownDescription": "Do not activate the `default` feature"
333 },
326 "rust-analyzer.checkOnSave.allFeatures": { 334 "rust-analyzer.checkOnSave.allFeatures": {
327 "type": [ 335 "type": [
328 "null", 336 "null",