Skip to content

Commit 723121e

Browse files
Merge pull request #19642 from ChayimFriedman2/fix-warn
fix: Two config code changes
2 parents 2f2cff1 + 8497fc3 commit 723121e

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

crates/rust-analyzer/src/config.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -921,10 +921,10 @@ impl Config {
921921
tracing::info!("updating config from JSON: {:#}", json);
922922

923923
if !(json.is_null() || json.as_object().is_some_and(|it| it.is_empty())) {
924-
let mut json_errors = vec![];
925924
let detached_files = get_field_json::<Vec<Utf8PathBuf>>(
926925
&mut json,
927-
&mut json_errors,
926+
// Do not record errors here; it is not an error if a field is missing here.
927+
&mut Vec::new(),
928928
"detachedFiles",
929929
None,
930930
)
@@ -935,15 +935,16 @@ impl Config {
935935

936936
patch_old_style::patch_json_for_outdated_configs(&mut json);
937937

938-
let mut json_errors = vec![];
939938
let snips = get_field_json::<FxIndexMap<String, SnippetDef>>(
940939
&mut json,
941-
&mut json_errors,
940+
// Do not record errors here; it is not an error if a field is missing here.
941+
&mut Vec::new(),
942942
"completion_snippets_custom",
943943
None,
944944
)
945945
.unwrap_or(self.completion_snippets_custom().to_owned());
946946

947+
let mut json_errors = vec![];
947948
// IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`.
948949
config.snippets.clear();
949950

@@ -2728,10 +2729,6 @@ pub enum NumThreads {
27282729
}
27292730

27302731
macro_rules! _default_val {
2731-
(@verbatim: $s:literal, $ty:ty) => {{
2732-
let default_: $ty = serde_json::from_str(&$s).unwrap();
2733-
default_
2734-
}};
27352732
($default:expr, $ty:ty) => {{
27362733
let default_: $ty = $default;
27372734
default_
@@ -2740,9 +2737,6 @@ macro_rules! _default_val {
27402737
use _default_val as default_val;
27412738

27422739
macro_rules! _default_str {
2743-
(@verbatim: $s:literal, $_ty:ty) => {
2744-
$s.to_owned()
2745-
};
27462740
($default:expr, $ty:ty) => {{
27472741
let val = default_val!($default, $ty);
27482742
serde_json::to_string_pretty(&val).unwrap()
@@ -2883,7 +2877,7 @@ macro_rules! _config_data {
28832877
($(#[doc=$dox:literal])* $modname:ident: struct $name:ident <- $input:ident -> {
28842878
$(
28852879
$(#[doc=$doc:literal])*
2886-
$vis:vis $field:ident $(| $alias:ident)*: $ty:ty = $(@$marker:ident: )? $default:expr,
2880+
$vis:vis $field:ident $(| $alias:ident)*: $ty:ty = $default:expr,
28872881
)*
28882882
}) => {
28892883
/// Default config values for this grouping.
@@ -2920,7 +2914,7 @@ macro_rules! _config_data {
29202914
impl Default for $name {
29212915
fn default() -> Self {
29222916
$name {$(
2923-
$field: default_val!($(@$marker:)? $default, $ty),
2917+
$field: default_val!($default, $ty),
29242918
)*}
29252919
}
29262920
}
@@ -2956,7 +2950,7 @@ macro_rules! _config_data {
29562950
$({
29572951
let field = stringify!($field);
29582952
let ty = stringify!($ty);
2959-
let default = default_str!($(@$marker:)? $default, $ty);
2953+
let default = default_str!($default, $ty);
29602954

29612955
(field, ty, &[$($doc),*], default)
29622956
},)*

0 commit comments

Comments
 (0)