Skip to content

Commit 6be61bc

Browse files
C4K3nrc
authored andcommitted
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.
1 parent 488c0b9 commit 6be61bc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/config.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,15 @@ macro_rules! create_config {
238238
}
239239

240240
pub fn from_toml(toml: &str) -> Config {
241-
let parsed = toml.parse().expect("Could not parse TOML");
241+
let parsed: toml::Value = toml.parse().expect("Could not parse TOML");
242+
for (key, _) in parsed.as_table().expect("Parsed config was not table") {
243+
match &**key {
244+
$(
245+
stringify!($i) => (),
246+
)+
247+
_ => msg!("Warning: Unused configuration option {}", key),
248+
}
249+
}
242250
let parsed_config:ParsedConfig = match toml::decode(parsed) {
243251
Some(decoded) => decoded,
244252
None => {

0 commit comments

Comments
 (0)