about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-10 19:15:06 +0000
committerbors <bors@rust-lang.org>2022-05-10 19:15:06 +0000
commitb350a1bf6f0bffe19b1bb64ae465188ff6f35d6d (patch)
tree1563e81ca846a3bc989e30cbb7b32011a3dc2f66
parent4d94cf34b8f53edb4a45e0301f7a9b6a735326e2 (diff)
parentb271ef8fd1a37c2eb1bdf0f1dd025d94c887fb81 (diff)
downloadrust-b350a1bf6f0bffe19b1bb64ae465188ff6f35d6d.tar.gz
rust-b350a1bf6f0bffe19b1bb64ae465188ff6f35d6d.zip
Auto merge of #12209 - Veykril:config-fix, r=Veykril
fix: Fix config patching failing when appending suffixes
-rw-r--r--crates/rust-analyzer/src/config/patch_old_style.rs32
1 files changed, 25 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/config/patch_old_style.rs b/crates/rust-analyzer/src/config/patch_old_style.rs
index 277364cefa0..ff0cb2b6398 100644
--- a/crates/rust-analyzer/src/config/patch_old_style.rs
+++ b/crates/rust-analyzer/src/config/patch_old_style.rs
@@ -11,13 +11,16 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
         ($(
             $($src:ident).+ -> $($dst:ident).+ ;
         )+) => { $(
-            if let Some(it) = copy.pointer(concat!($("/", stringify!($src)),+)).cloned() {
-                let mut last = it;
-                for segment in [$(stringify!($dst)),+].into_iter().rev() {
-                    last = Value::Object(serde_json::Map::from_iter(std::iter::once((segment.to_string(), last))));
-                }
+            match copy.pointer(concat!($("/", stringify!($src)),+)).cloned() {
+                Some(Value::Object(_)) | None => (),
+                Some(it) => {
+                    let mut last = it;
+                    for segment in [$(stringify!($dst)),+].into_iter().rev() {
+                        last = Value::Object(serde_json::Map::from_iter(std::iter::once((segment.to_string(), last))));
+                    }
 
-                merge(json, last);
+                    merge(json, last);
+                },
             }
         )+ };
     }
@@ -36,7 +39,6 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
         cargo.runBuildScripts -> cargo.runBuildScripts.overrideCommand;
         cargo.runBuildScriptsCommand -> cargo.runBuildScripts.overrideCommand;
         cargo.useRustcWrapperForBuildScripts -> cargo.runBuildScripts.useRustcWrapper;
-        completion.snippets -> completion.snippets.custom;
         diagnostics.enableExperimental -> diagnostics.experimental.enable;
         experimental.procAttrMacros -> procMacro.attributes.enable;
         highlighting.strings -> semanticHighlighting.strings.enable;
@@ -66,6 +68,22 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
         rustfmt.enableRangeFormatting -> rustfmt.rangeFormatting.enable;
     }
 
+    // completion.snippets -> completion.snippets.custom;
+    if let Some(Value::Object(obj)) = copy.pointer("/completion/snippets").cloned() {
+        if obj.len() != 1 || obj.get("custom").is_none() {
+            merge(
+                json,
+                json! {{
+                    "completion": {
+                        "snippets": {
+                            "custom": obj
+                        },
+                    },
+                }},
+            );
+        }
+    }
+
     // callInfo_full -> signatureInfo_detail, signatureInfo_documentation_enable
     if let Some(Value::Bool(b)) = copy.pointer("/callInfo/full") {
         let sig_info = match b {