Skip to content

Commit

Permalink
Warn on unused config options (#1402)
Browse files Browse the repository at this point in the history
This will make it clear if a user has misspelled a config option, or if
an option has been changed/removed.
  • Loading branch information
C4K3 authored and nrc committed Mar 26, 2017
1 parent 488c0b9 commit 6be61bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/config.rs
Expand Up @@ -238,7 +238,15 @@ macro_rules! create_config {
}

pub fn from_toml(toml: &str) -> Config {
let parsed = toml.parse().expect("Could not parse TOML");
let parsed: toml::Value = toml.parse().expect("Could not parse TOML");
for (key, _) in parsed.as_table().expect("Parsed config was not table") {
match &**key {
$(
stringify!($i) => (),
)+
_ => msg!("Warning: Unused configuration option {}", key),
}
}
let parsed_config:ParsedConfig = match toml::decode(parsed) {
Some(decoded) => decoded,
None => {
Expand Down

0 comments on commit 6be61bc

Please sign in to comment.