From 6be61bcdd6252b529f5a14765fb7cb01be943f66 Mon Sep 17 00:00:00 2001 From: C4K3 Date: Sun, 26 Mar 2017 07:12:56 +0200 Subject: [PATCH] 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. --- src/config.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 92a5aa7611ed..78c6b91526f0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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 => {