Skip to content

Commit 6568e8f

Browse files
authored
Merge pull request #19628 from jyn514/warn-bad-config
don't ignore config values that fail to parse
2 parents a09a550 + 46ce474 commit 6568e8f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

crates/rust-analyzer/src/config.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -1382,18 +1382,21 @@ impl ConfigErrors {
13821382

13831383
impl fmt::Display for ConfigErrors {
13841384
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1385-
let errors = self.0.iter().format_with("\n", |inner, f| match &**inner {
1386-
ConfigErrorInner::Json { config_key: key, error: e } => {
1387-
f(key)?;
1388-
f(&": ")?;
1389-
f(e)
1390-
}
1391-
ConfigErrorInner::Toml { config_key: key, error: e } => {
1392-
f(key)?;
1393-
f(&": ")?;
1394-
f(e)
1395-
}
1396-
ConfigErrorInner::ParseError { reason } => f(reason),
1385+
let errors = self.0.iter().format_with("\n", |inner, f| {
1386+
match &**inner {
1387+
ConfigErrorInner::Json { config_key: key, error: e } => {
1388+
f(key)?;
1389+
f(&": ")?;
1390+
f(e)
1391+
}
1392+
ConfigErrorInner::Toml { config_key: key, error: e } => {
1393+
f(key)?;
1394+
f(&": ")?;
1395+
f(e)
1396+
}
1397+
ConfigErrorInner::ParseError { reason } => f(reason),
1398+
}?;
1399+
f(&";")
13971400
});
13981401
write!(f, "invalid config value{}:\n{}", if self.0.len() == 1 { "" } else { "s" }, errors)
13991402
}
@@ -3091,15 +3094,15 @@ fn get_field_json<T: DeserializeOwned>(
30913094
json.pointer_mut(&pointer)
30923095
.map(|it| serde_json::from_value(it.take()).map_err(|e| (e, pointer)))
30933096
})
3094-
.find(Result::is_ok)
3095-
.and_then(|res| match res {
3097+
.flat_map(|res| match res {
30963098
Ok(it) => Some(it),
30973099
Err((e, pointer)) => {
30983100
tracing::warn!("Failed to deserialize config field at {}: {:?}", pointer, e);
30993101
error_sink.push((pointer, e));
31003102
None
31013103
}
31023104
})
3105+
.next()
31033106
}
31043107

31053108
fn get_field_toml<T: DeserializeOwned>(

0 commit comments

Comments
 (0)