Skip to content

Commit 97f1948

Browse files
committed
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.
1 parent 1bc2ebd commit 97f1948

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/config.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,11 @@ fn parse_env(key: &str) -> Option<String> {
381381
fn warn_on_invalid_fields(table: &Value) {
382382
let valid_items = ["book", "build", "rust", "output", "preprocessor"];
383383

384-
if let Some(table) = table.as_table() {
385-
for item in table.keys() {
386-
if !valid_items.contains(&item.as_str()) {
387-
warn!("Invalid field {:?} in book.toml", &item);
388-
}
384+
let table = table.as_table().expect("root must be a table");
385+
for item in table.keys() {
386+
if !valid_items.contains(&item.as_str()) {
387+
warn!("Invalid field {:?} in book.toml", &item);
389388
}
390-
} else {
391-
warn!("Invalid format in book.toml");
392389
}
393390
}
394391

0 commit comments

Comments
 (0)