flycheck: Added checkOnSave.noDefaultFeatures

This commit adds the option
`rust-analyzer.checkOnSave.noDefaultFeatures`
and fixes #5550.
This commit is contained in:
Clemens Wasser 2020-07-30 16:04:01 +02:00
parent 96c3ff1c57
commit 8d9f8ac273
3 changed files with 23 additions and 3 deletions

View File

@ -24,6 +24,7 @@ pub enum FlycheckConfig {
command: String, command: String,
target_triple: Option<String>, target_triple: Option<String>,
all_targets: bool, all_targets: bool,
no_default_features: bool,
all_features: bool, all_features: bool,
features: Vec<String>, features: Vec<String>,
extra_args: Vec<String>, extra_args: Vec<String>,
@ -180,6 +181,7 @@ fn check_command(&self) -> Command {
FlycheckConfig::CargoCommand { FlycheckConfig::CargoCommand {
command, command,
target_triple, target_triple,
no_default_features,
all_targets, all_targets,
all_features, all_features,
extra_args, extra_args,
@ -198,10 +200,15 @@ fn check_command(&self) -> Command {
} }
if *all_features { if *all_features {
cmd.arg("--all-features"); cmd.arg("--all-features");
} else if !features.is_empty() { } else {
if *no_default_features {
cmd.arg("--no-default-features");
}
if !features.is_empty() {
cmd.arg("--features"); cmd.arg("--features");
cmd.arg(features.join(" ")); cmd.arg(features.join(" "));
} }
}
cmd.args(extra_args); cmd.args(extra_args);
cmd cmd
} }

View File

@ -151,6 +151,7 @@ pub fn new(root_path: AbsPathBuf) -> Self {
flycheck: Some(FlycheckConfig::CargoCommand { flycheck: Some(FlycheckConfig::CargoCommand {
command: "check".to_string(), command: "check".to_string(),
target_triple: None, target_triple: None,
no_default_features: false,
all_targets: true, all_targets: true,
all_features: false, all_features: false,
extra_args: Vec::new(), extra_args: Vec::new(),
@ -234,6 +235,9 @@ pub fn update(&mut self, json: serde_json::Value) {
command: data.checkOnSave_command, command: data.checkOnSave_command,
target_triple: data.checkOnSave_target.or(data.cargo_target), target_triple: data.checkOnSave_target.or(data.cargo_target),
all_targets: data.checkOnSave_allTargets, all_targets: data.checkOnSave_allTargets,
no_default_features: data
.checkOnSave_noDefaultFeatures
.unwrap_or(data.cargo_noDefaultFeatures),
all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures),
features: data.checkOnSave_features.unwrap_or(data.cargo_features), features: data.checkOnSave_features.unwrap_or(data.cargo_features),
extra_args: data.checkOnSave_extraArgs, extra_args: data.checkOnSave_extraArgs,
@ -398,6 +402,7 @@ struct ConfigData {
checkOnSave_allFeatures: Option<bool> = None, checkOnSave_allFeatures: Option<bool> = None,
checkOnSave_allTargets: bool = true, checkOnSave_allTargets: bool = true,
checkOnSave_command: String = "check".into(), checkOnSave_command: String = "check".into(),
checkOnSave_noDefaultFeatures: Option<bool> = None,
checkOnSave_target: Option<String> = None, checkOnSave_target: Option<String> = None,
checkOnSave_extraArgs: Vec<String> = Vec::new(), checkOnSave_extraArgs: Vec<String> = Vec::new(),
checkOnSave_features: Option<Vec<String>> = None, checkOnSave_features: Option<Vec<String>> = None,

View File

@ -323,6 +323,14 @@
"default": true, "default": true,
"markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
}, },
"rust-analyzer.checkOnSave.noDefaultFeatures": {
"type": [
"null",
"boolean"
],
"default": null,
"markdownDescription": "Do not activate the `default` feature"
},
"rust-analyzer.checkOnSave.allFeatures": { "rust-analyzer.checkOnSave.allFeatures": {
"type": [ "type": [
"null", "null",