Skip to content

Commit 8d9f8ac

Browse files
committed
flycheck: Added checkOnSave.noDefaultFeatures
This commit adds the option `rust-analyzer.checkOnSave.noDefaultFeatures` and fixes #5550.
1 parent 96c3ff1 commit 8d9f8ac

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

crates/flycheck/src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum FlycheckConfig {
2424
command: String,
2525
target_triple: Option<String>,
2626
all_targets: bool,
27+
no_default_features: bool,
2728
all_features: bool,
2829
features: Vec<String>,
2930
extra_args: Vec<String>,
@@ -180,6 +181,7 @@ impl FlycheckActor {
180181
FlycheckConfig::CargoCommand {
181182
command,
182183
target_triple,
184+
no_default_features,
183185
all_targets,
184186
all_features,
185187
extra_args,
@@ -198,9 +200,14 @@ impl FlycheckActor {
198200
}
199201
if *all_features {
200202
cmd.arg("--all-features");
201-
} else if !features.is_empty() {
202-
cmd.arg("--features");
203-
cmd.arg(features.join(" "));
203+
} else {
204+
if *no_default_features {
205+
cmd.arg("--no-default-features");
206+
}
207+
if !features.is_empty() {
208+
cmd.arg("--features");
209+
cmd.arg(features.join(" "));
210+
}
204211
}
205212
cmd.args(extra_args);
206213
cmd

crates/rust-analyzer/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ impl Config {
151151
flycheck: Some(FlycheckConfig::CargoCommand {
152152
command: "check".to_string(),
153153
target_triple: None,
154+
no_default_features: false,
154155
all_targets: true,
155156
all_features: false,
156157
extra_args: Vec::new(),
@@ -234,6 +235,9 @@ impl Config {
234235
command: data.checkOnSave_command,
235236
target_triple: data.checkOnSave_target.or(data.cargo_target),
236237
all_targets: data.checkOnSave_allTargets,
238+
no_default_features: data
239+
.checkOnSave_noDefaultFeatures
240+
.unwrap_or(data.cargo_noDefaultFeatures),
237241
all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures),
238242
features: data.checkOnSave_features.unwrap_or(data.cargo_features),
239243
extra_args: data.checkOnSave_extraArgs,
@@ -398,6 +402,7 @@ config_data! {
398402
checkOnSave_allFeatures: Option<bool> = None,
399403
checkOnSave_allTargets: bool = true,
400404
checkOnSave_command: String = "check".into(),
405+
checkOnSave_noDefaultFeatures: Option<bool> = None,
401406
checkOnSave_target: Option<String> = None,
402407
checkOnSave_extraArgs: Vec<String> = Vec::new(),
403408
checkOnSave_features: Option<Vec<String>> = None,

editors/code/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,14 @@
323323
"default": true,
324324
"markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
325325
},
326+
"rust-analyzer.checkOnSave.noDefaultFeatures": {
327+
"type": [
328+
"null",
329+
"boolean"
330+
],
331+
"default": null,
332+
"markdownDescription": "Do not activate the `default` feature"
333+
},
326334
"rust-analyzer.checkOnSave.allFeatures": {
327335
"type": [
328336
"null",

0 commit comments

Comments
 (0)