Warn on unused config options (#1402)

This will make it clear if a user has misspelled a config option, or if
an option has been changed/removed.
This commit is contained in:
C4K3 2017-03-26 07:12:56 +02:00 committed by Nick Cameron
parent 488c0b9546
commit 6be61bcdd6

View file

@ -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 => {