From 97f19486817726965e6c4b9b9839dae0b5893f30 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 3 Apr 2025 11:17:25 -0700 Subject: [PATCH] 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. --- src/config.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/config.rs b/src/config.rs index f4eab968..db159a45 100644 --- a/src/config.rs +++ b/src/config.rs @@ -381,14 +381,11 @@ fn parse_env(key: &str) -> Option { 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"); } }