mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 18:26:19 +00:00
Merge pull request #19628 from jyn514/warn-bad-config
don't ignore config values that fail to parse
This commit is contained in:
commit
6568e8f12d
1 changed files with 17 additions and 14 deletions
|
|
@ -1382,18 +1382,21 @@ impl ConfigErrors {
|
||||||
|
|
||||||
impl fmt::Display for ConfigErrors {
|
impl fmt::Display for ConfigErrors {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let errors = self.0.iter().format_with("\n", |inner, f| match &**inner {
|
let errors = self.0.iter().format_with("\n", |inner, f| {
|
||||||
ConfigErrorInner::Json { config_key: key, error: e } => {
|
match &**inner {
|
||||||
f(key)?;
|
ConfigErrorInner::Json { config_key: key, error: e } => {
|
||||||
f(&": ")?;
|
f(key)?;
|
||||||
f(e)
|
f(&": ")?;
|
||||||
}
|
f(e)
|
||||||
ConfigErrorInner::Toml { config_key: key, error: e } => {
|
}
|
||||||
f(key)?;
|
ConfigErrorInner::Toml { config_key: key, error: e } => {
|
||||||
f(&": ")?;
|
f(key)?;
|
||||||
f(e)
|
f(&": ")?;
|
||||||
}
|
f(e)
|
||||||
ConfigErrorInner::ParseError { reason } => f(reason),
|
}
|
||||||
|
ConfigErrorInner::ParseError { reason } => f(reason),
|
||||||
|
}?;
|
||||||
|
f(&";")
|
||||||
});
|
});
|
||||||
write!(f, "invalid config value{}:\n{}", if self.0.len() == 1 { "" } else { "s" }, errors)
|
write!(f, "invalid config value{}:\n{}", if self.0.len() == 1 { "" } else { "s" }, errors)
|
||||||
}
|
}
|
||||||
|
|
@ -3091,8 +3094,7 @@ fn get_field_json<T: DeserializeOwned>(
|
||||||
json.pointer_mut(&pointer)
|
json.pointer_mut(&pointer)
|
||||||
.map(|it| serde_json::from_value(it.take()).map_err(|e| (e, pointer)))
|
.map(|it| serde_json::from_value(it.take()).map_err(|e| (e, pointer)))
|
||||||
})
|
})
|
||||||
.find(Result::is_ok)
|
.flat_map(|res| match res {
|
||||||
.and_then(|res| match res {
|
|
||||||
Ok(it) => Some(it),
|
Ok(it) => Some(it),
|
||||||
Err((e, pointer)) => {
|
Err((e, pointer)) => {
|
||||||
tracing::warn!("Failed to deserialize config field at {}: {:?}", pointer, e);
|
tracing::warn!("Failed to deserialize config field at {}: {:?}", pointer, e);
|
||||||
|
|
@ -3100,6 +3102,7 @@ fn get_field_json<T: DeserializeOwned>(
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_field_toml<T: DeserializeOwned>(
|
fn get_field_toml<T: DeserializeOwned>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue