Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ impl<'de> serde::Deserialize<'de> for Config {
return Ok(Config::from_legacy(raw));
}

warn_on_invalid_fields(&raw);

use serde::de::Error;
let mut table = match raw {
Value::Table(t) => t,
Expand Down Expand Up @@ -376,6 +378,17 @@ fn parse_env(key: &str) -> Option<String> {
.map(|key| key.to_lowercase().replace("__", ".").replace('_', "-"))
}

fn warn_on_invalid_fields(table: &Value) {
let valid_items = ["book", "build", "rust", "output", "preprocessor"];

let table = table.as_table().expect("root must be a table");
for item in table.keys() {
if !valid_items.contains(&item.as_str()) {
warn!("Invalid field {:?} in book.toml", &item);
}
}
}

fn is_legacy_format(table: &Value) -> bool {
let legacy_items = [
"title",
Expand Down