mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Fix: Handle empty checkOnSave/target
values
This fixes a regression introduced by #13290, in which failing to set `checkOnSave/target` (or `checkOnSave/targets`) would lead to an invalid config.
This commit is contained in:
parent
26562973b3
commit
b116fe9be0
3 changed files with 19 additions and 8 deletions
|
@ -182,7 +182,7 @@ config_data! {
|
|||
/// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
|
||||
///
|
||||
/// Aliased as `"checkOnSave.targets"`.
|
||||
checkOnSave_target | checkOnSave_targets: CheckOnSaveTargets = "[]",
|
||||
checkOnSave_target | checkOnSave_targets: Option<CheckOnSaveTargets> = "null",
|
||||
|
||||
/// Toggles the additional completions that automatically add imports when completed.
|
||||
/// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
|
||||
|
@ -1153,10 +1153,15 @@ impl Config {
|
|||
}
|
||||
Some(_) | None => FlycheckConfig::CargoCommand {
|
||||
command: self.data.checkOnSave_command.clone(),
|
||||
target_triples: match &self.data.checkOnSave_target.0[..] {
|
||||
[] => self.data.cargo_target.clone().into_iter().collect(),
|
||||
targets => targets.into(),
|
||||
},
|
||||
target_triples: self
|
||||
.data
|
||||
.checkOnSave_target
|
||||
.clone()
|
||||
.and_then(|targets| match &targets.0[..] {
|
||||
[] => None,
|
||||
targets => Some(targets.into()),
|
||||
})
|
||||
.unwrap_or_else(|| self.data.cargo_target.clone().into_iter().collect()),
|
||||
all_targets: self.data.checkOnSave_allTargets,
|
||||
no_default_features: self
|
||||
.data
|
||||
|
@ -2126,8 +2131,11 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
|||
"The command will be executed in the project root."
|
||||
],
|
||||
},
|
||||
"CheckOnSaveTargets" => set! {
|
||||
"Option<CheckOnSaveTargets>" => set! {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
},
|
||||
|
|
|
@ -190,7 +190,7 @@ cargo check --workspace --message-format=json --all-targets
|
|||
```
|
||||
.
|
||||
--
|
||||
[[rust-analyzer.checkOnSave.target]]rust-analyzer.checkOnSave.target (default: `[]`)::
|
||||
[[rust-analyzer.checkOnSave.target]]rust-analyzer.checkOnSave.target (default: `null`)::
|
||||
+
|
||||
--
|
||||
Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
|
||||
|
|
|
@ -640,8 +640,11 @@
|
|||
},
|
||||
"rust-analyzer.checkOnSave.target": {
|
||||
"markdownDescription": "Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.\n\nCan be a single target, e.g. `\"x86_64-unknown-linux-gnu\"` or a list of targets, e.g.\n`[\"aarch64-apple-darwin\", \"x86_64-apple-darwin\"]`.\n\nAliased as `\"checkOnSave.targets\"`.",
|
||||
"default": [],
|
||||
"default": null,
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue