Skip to content

Commit b350a1b

Browse files
committed
Auto merge of rust-lang#12209 - Veykril:config-fix, r=Veykril
fix: Fix config patching failing when appending suffixes
2 parents 4d94cf3 + b271ef8 commit b350a1b

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

crates/rust-analyzer/src/config/patch_old_style.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
1111
($(
1212
$($src:ident).+ -> $($dst:ident).+ ;
1313
)+) => { $(
14-
if let Some(it) = copy.pointer(concat!($("/", stringify!($src)),+)).cloned() {
15-
let mut last = it;
16-
for segment in [$(stringify!($dst)),+].into_iter().rev() {
17-
last = Value::Object(serde_json::Map::from_iter(std::iter::once((segment.to_string(), last))));
18-
}
14+
match copy.pointer(concat!($("/", stringify!($src)),+)).cloned() {
15+
Some(Value::Object(_)) | None => (),
16+
Some(it) => {
17+
let mut last = it;
18+
for segment in [$(stringify!($dst)),+].into_iter().rev() {
19+
last = Value::Object(serde_json::Map::from_iter(std::iter::once((segment.to_string(), last))));
20+
}
1921

20-
merge(json, last);
22+
merge(json, last);
23+
},
2124
}
2225
)+ };
2326
}
@@ -36,7 +39,6 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
3639
cargo.runBuildScripts -> cargo.runBuildScripts.overrideCommand;
3740
cargo.runBuildScriptsCommand -> cargo.runBuildScripts.overrideCommand;
3841
cargo.useRustcWrapperForBuildScripts -> cargo.runBuildScripts.useRustcWrapper;
39-
completion.snippets -> completion.snippets.custom;
4042
diagnostics.enableExperimental -> diagnostics.experimental.enable;
4143
experimental.procAttrMacros -> procMacro.attributes.enable;
4244
highlighting.strings -> semanticHighlighting.strings.enable;
@@ -66,6 +68,22 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
6668
rustfmt.enableRangeFormatting -> rustfmt.rangeFormatting.enable;
6769
}
6870

71+
// completion.snippets -> completion.snippets.custom;
72+
if let Some(Value::Object(obj)) = copy.pointer("/completion/snippets").cloned() {
73+
if obj.len() != 1 || obj.get("custom").is_none() {
74+
merge(
75+
json,
76+
json! {{
77+
"completion": {
78+
"snippets": {
79+
"custom": obj
80+
},
81+
},
82+
}},
83+
);
84+
}
85+
}
86+
6987
// callInfo_full -> signatureInfo_detail, signatureInfo_documentation_enable
7088
if let Some(Value::Bool(b)) = copy.pointer("/callInfo/full") {
7189
let sig_info = match b {

0 commit comments

Comments
 (0)