From c85f63d42e589c7a77d0620fdb3f91679f02949c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 21 Apr 2025 08:09:35 +0200 Subject: [PATCH 1/2] Back out "When changing the config, do not emit an error if a field is missing" This backs out commit 8497fc321cad420b923e15f600106f8e22324930. --- .../rust-analyzer/crates/rust-analyzer/src/config.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 1f44889883fc..41fa7b4fbb81 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -921,10 +921,10 @@ impl Config { tracing::info!("updating config from JSON: {:#}", json); if !(json.is_null() || json.as_object().is_some_and(|it| it.is_empty())) { + let mut json_errors = vec![]; let detached_files = get_field_json::>( &mut json, - // Do not record errors here; it is not an error if a field is missing here. - &mut Vec::new(), + &mut json_errors, "detachedFiles", None, ) @@ -935,16 +935,15 @@ impl Config { patch_old_style::patch_json_for_outdated_configs(&mut json); + let mut json_errors = vec![]; let snips = get_field_json::>( &mut json, - // Do not record errors here; it is not an error if a field is missing here. - &mut Vec::new(), + &mut json_errors, "completion_snippets_custom", None, ) .unwrap_or(self.completion_snippets_custom().to_owned()); - let mut json_errors = vec![]; // IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`. config.snippets.clear(); From 5d12827099a2c9927f8f3213d2048d2543a6fddc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 20 Apr 2025 13:26:24 +0200 Subject: [PATCH 2/2] fix: Fix completion_snippets_custom config always erroring --- .../crates/rust-analyzer/src/config.rs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 41fa7b4fbb81..619cf3d50115 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -921,10 +921,9 @@ impl Config { tracing::info!("updating config from JSON: {:#}", json); if !(json.is_null() || json.as_object().is_some_and(|it| it.is_empty())) { - let mut json_errors = vec![]; let detached_files = get_field_json::>( &mut json, - &mut json_errors, + &mut Vec::new(), "detachedFiles", None, ) @@ -936,17 +935,19 @@ impl Config { patch_old_style::patch_json_for_outdated_configs(&mut json); let mut json_errors = vec![]; - let snips = get_field_json::>( - &mut json, - &mut json_errors, - "completion_snippets_custom", - None, - ) - .unwrap_or(self.completion_snippets_custom().to_owned()); + + let input = FullConfigInput::from_json(json, &mut json_errors); // IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`. config.snippets.clear(); + let snips = input + .global + .completion_snippets_custom + .as_ref() + .unwrap_or(&self.default_config.global.completion_snippets_custom); + #[allow(dead_code)] + let _ = Self::completion_snippets_custom; for (name, def) in snips.iter() { if def.prefix.is_empty() && def.postfix.is_empty() { continue; @@ -973,8 +974,9 @@ impl Config { )), } } + config.client_config = ( - FullConfigInput::from_json(json, &mut json_errors), + input, ConfigErrors( json_errors .into_iter()