summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2023-06-17 22:41:28 +0200
committerGitHub <noreply@github.com>2023-06-17 20:41:28 +0000
commitcb48ac92071c43a9163329b66b5f74a7fb3dca69 (patch)
tree8f0a497b3588bbcc959d99a4178cb11266a9bfc3
parent474ee4bb75d06e9dfcf4a050fb738b45f8dd9135 (diff)
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.
-rw-r--r--alacritty/src/config/color.rs1
-rw-r--r--alacritty/src/config/ui_config.rs1
-rw-r--r--alacritty_terminal/src/config/mod.rs4
3 files changed, 4 insertions, 2 deletions
diff --git a/alacritty/src/config/color.rs b/alacritty/src/config/color.rs
index e08b08b4..2ded7f04 100644
--- a/alacritty/src/config/color.rs
+++ b/alacritty/src/config/color.rs
@@ -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,
diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs
index c4a1c83d..658d2ea8 100644
--- a/alacritty/src/config/ui_config.rs
+++ b/alacritty/src/config/ui_config.rs
@@ -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)]
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs
index 2d921b6e..80be4d16 100644
--- a/alacritty_terminal/src/config/mod.rs
+++ b/alacritty_terminal/src/config/mod.rs
@@ -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 {