mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Merge #4822
4822: Let checkOnSafe default to some of the options of cargo r=matklad a=clemenswasser This will fix #4631 The implementation works (as far as I have tested) but is suboptimal because I am copying the "cargo.features". Co-authored-by: Clemens Wasser <clemens.wasser@gmail.com>
This commit is contained in:
commit
560b98bc50
@ -18,8 +18,17 @@ pub use cargo_metadata::diagnostic::{
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum FlycheckConfig {
|
||||
CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec<String> },
|
||||
CustomCommand { command: String, args: Vec<String> },
|
||||
CargoCommand {
|
||||
command: String,
|
||||
all_targets: bool,
|
||||
all_features: bool,
|
||||
features: Vec<String>,
|
||||
extra_args: Vec<String>,
|
||||
},
|
||||
CustomCommand {
|
||||
command: String,
|
||||
args: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Flycheck wraps the shared state and communication machinery used for
|
||||
@ -188,7 +197,13 @@ impl FlycheckThread {
|
||||
self.check_process = None;
|
||||
|
||||
let mut cmd = match &self.config {
|
||||
FlycheckConfig::CargoCommand { command, all_targets, all_features, extra_args } => {
|
||||
FlycheckConfig::CargoCommand {
|
||||
command,
|
||||
all_targets,
|
||||
all_features,
|
||||
extra_args,
|
||||
features,
|
||||
} => {
|
||||
let mut cmd = Command::new(ra_toolchain::cargo());
|
||||
cmd.arg(command);
|
||||
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
|
||||
@ -198,6 +213,9 @@ impl FlycheckThread {
|
||||
}
|
||||
if *all_features {
|
||||
cmd.arg("--all-features");
|
||||
} else if !features.is_empty() {
|
||||
cmd.arg("--features");
|
||||
cmd.arg(features.join(" "));
|
||||
}
|
||||
cmd.args(extra_args);
|
||||
cmd
|
||||
|
@ -147,6 +147,7 @@ impl Default for Config {
|
||||
all_targets: true,
|
||||
all_features: false,
|
||||
extra_args: Vec::new(),
|
||||
features: Vec::new(),
|
||||
}),
|
||||
|
||||
inlay_hints: InlayHintsConfig {
|
||||
@ -234,13 +235,14 @@ impl Config {
|
||||
}
|
||||
// otherwise configure command customizations
|
||||
_ => {
|
||||
if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_features })
|
||||
if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_features, features })
|
||||
= &mut self.check
|
||||
{
|
||||
set(value, "/checkOnSave/extraArgs", extra_args);
|
||||
set(value, "/checkOnSave/command", command);
|
||||
set(value, "/checkOnSave/allTargets", all_targets);
|
||||
set(value, "/checkOnSave/allFeatures", all_features);
|
||||
*all_features = get(value, "/checkOnSave/allFeatures").unwrap_or(self.cargo.all_features);
|
||||
*features = get(value, "/checkOnSave/features").unwrap_or(self.cargo.features.clone());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -318,9 +318,23 @@
|
||||
"markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
|
||||
},
|
||||
"rust-analyzer.checkOnSave.allFeatures": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"markdownDescription": "Check with all features (will be passed as `--all-features`)"
|
||||
"type": [
|
||||
"null",
|
||||
"boolean"
|
||||
],
|
||||
"default": null,
|
||||
"markdownDescription": "Check with all features (will be passed as `--all-features`). Defaults to `rust-analyzer.cargo.allFeatures`."
|
||||
},
|
||||
"rust-analyzer.checkOnSave.features": {
|
||||
"type": [
|
||||
"null",
|
||||
"array"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": null,
|
||||
"description": "List of features to activate. Defaults to `rust-analyzer.cargo.features`."
|
||||
},
|
||||
"rust-analyzer.inlayHints.enable": {
|
||||
"type": "boolean",
|
||||
|
Loading…
Reference in New Issue
Block a user