Make the unexpected case explicit that it is an internal error

The current code has the `else` clause as unreachable, and the text it
has isn't clear that is the case.
This commit is contained in:
Eric Huss 2025-04-03 11:17:25 -07:00
parent 1bc2ebd775
commit 97f1948681

View file

@ -381,14 +381,11 @@ fn parse_env(key: &str) -> Option<String> {
fn warn_on_invalid_fields(table: &Value) {
let valid_items = ["book", "build", "rust", "output", "preprocessor"];
if let Some(table) = table.as_table() {
for item in table.keys() {
if !valid_items.contains(&item.as_str()) {
warn!("Invalid field {:?} in book.toml", &item);
}
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);
}
} else {
warn!("Invalid format in book.toml");
}
}