Skip to content

Commit 670962c

Browse files
committed
install: Warn on unknown keys
Out of general principle, since we're adding new ones. Signed-off-by: Colin Walters <[email protected]>
1 parent ee35410 commit 670962c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ regex = "1.7.1"
3434
rustix = { "version" = "0.38", features = ["thread", "fs", "system", "process"] }
3535
schemars = { version = "0.8.6", features = ["chrono"] }
3636
serde = { features = ["derive"], version = "1.0.125" }
37+
serde_ignored = "0.1.9"
3738
serde_json = "1.0.64"
3839
serde_yaml = "0.9.17"
3940
serde_with = ">= 1.9.4, < 2"

lib/src/install.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,15 @@ pub(crate) mod config {
405405
let mut config: Option<InstallConfiguration> = None;
406406
for (_name, path) in fragments {
407407
let buf = std::fs::read_to_string(&path)?;
408-
let c: InstallConfigurationToplevel =
409-
toml::from_str(&buf).with_context(|| format!("Parsing {path:?}"))?;
408+
let mut unused = std::collections::HashSet::new();
409+
let de = toml::Deserializer::new(&buf);
410+
let c: InstallConfigurationToplevel = serde_ignored::deserialize(de, |path| {
411+
unused.insert(path.to_string());
412+
})
413+
.with_context(|| format!("Parsing {path:?}"))?;
414+
for key in unused {
415+
eprintln!("warning: {path:?}: Unknown key {key}");
416+
}
410417
if let Some(config) = config.as_mut() {
411418
if let Some(install) = c.install {
412419
config.merge(install);

0 commit comments

Comments
 (0)