Skip to content

Commit 00ece98

Browse files
committed
Fix: Handle empty checkOnSave/target values
This fixes a regression introduced by rust-lang#13290, in which failing to set `checkOnSave/target` (or `checkOnSave/targets`) would lead to an invalid config.
1 parent 2656297 commit 00ece98

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ config_data! {
182182
/// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
183183
///
184184
/// Aliased as `"checkOnSave.targets"`.
185-
checkOnSave_target | checkOnSave_targets: CheckOnSaveTargets = "[]",
185+
checkOnSave_target | checkOnSave_targets: Option<CheckOnSaveTargets> = "null",
186186

187187
/// Toggles the additional completions that automatically add imports when completed.
188188
/// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
@@ -1153,10 +1153,15 @@ impl Config {
11531153
}
11541154
Some(_) | None => FlycheckConfig::CargoCommand {
11551155
command: self.data.checkOnSave_command.clone(),
1156-
target_triples: match &self.data.checkOnSave_target.0[..] {
1157-
[] => self.data.cargo_target.clone().into_iter().collect(),
1158-
targets => targets.into(),
1159-
},
1156+
target_triples: self
1157+
.data
1158+
.checkOnSave_target
1159+
.clone()
1160+
.and_then(|targets| match &targets.0[..] {
1161+
[] => None,
1162+
targets => Some(targets.into()),
1163+
})
1164+
.unwrap_or_else(|| self.data.cargo_target.clone().into_iter().collect()),
11601165
all_targets: self.data.checkOnSave_allTargets,
11611166
no_default_features: self
11621167
.data

0 commit comments

Comments
 (0)