Add errors for deserializing with unknown fields

Currently there are still some places where `Deserialize` is used rather
than `ConfigDeserialize`, which means that the built-in warning for
unused fields is not emitted automatically.

To ensure users don't have invalid configurations, the
`#[serde(deny_unknown_fields)]` annotation has been added to these
structs, making it a hard error when an unknown field is present.
This commit is contained in:
Christian Duerr 2023-06-17 22:41:28 +02:00 committed by GitHub
parent 474ee4bb75
commit cb48ac9207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View File

@ -75,6 +75,7 @@ impl Default for HintEndColors {
}
#[derive(Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct IndexedColor {
pub color: Rgb,

View File

@ -455,6 +455,7 @@ impl<'de> Deserialize<'de> for HintContent {
/// Binding for triggering a keyboard hint.
#[derive(Deserialize, Copy, Clone, Debug, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct HintBinding {
pub key: Key,
#[serde(default)]

View File

@ -127,7 +127,7 @@ impl Cursor {
}
#[derive(SerdeReplace, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
#[serde(untagged)]
#[serde(untagged, deny_unknown_fields)]
pub enum ConfigCursorStyle {
Shape(CursorShapeShim),
WithBlinking {
@ -191,7 +191,7 @@ impl From<CursorBlinking> for bool {
}
#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(untagged)]
#[serde(untagged, deny_unknown_fields)]
pub enum Program {
Just(String),
WithArgs {