Add unreachable comments.

This commit is contained in:
Stephen Chung 2022-07-23 21:00:58 +08:00
parent f85ad28e93
commit e8d6e3f57d
5 changed files with 8 additions and 8 deletions

View File

@ -200,7 +200,7 @@ pub fn generate_body(
let ns_str = syn::Ident::new(
match namespace {
FnNamespaceAccess::Unset => unreachable!(),
FnNamespaceAccess::Unset => unreachable!("`namespace` should be set"),
FnNamespaceAccess::Global => "Global",
FnNamespaceAccess::Internal => "Internal",
},

View File

@ -895,7 +895,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
*stmt = stmt_block.into();
}
Expr::Stmt(..) => *stmt = Stmt::Noop(expr.position()),
_ => unreachable!(),
_ => unreachable!("`Expr::Stmt`"),
}
}
@ -950,7 +950,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, _chaining: bool) {
optimize_expr(&mut e, state, false);
*expr = *e;
}
_ => unreachable!()
_ => unreachable!("`Expr::Stmt`")
}
}
// { stmt; ... } - do not count promotion as dirty because it gets turned back into an array

View File

@ -105,7 +105,7 @@ impl<T: Debug + Copy + PartialOrd> Iterator for StepRange<T> {
self.dir = 0;
}
} else {
unreachable!();
unreachable!("`dir` != 0");
}
Some(v)

View File

@ -798,7 +798,7 @@ impl Engine {
match token {
Token::LeftBracket => ASTFlags::NONE,
Token::QuestionBracket => ASTFlags::NEGATED,
_ => unreachable!(),
_ => unreachable!("`[` or `?[`"),
},
false,
settings.level_up(),
@ -1693,7 +1693,7 @@ impl Engine {
let opt = match token {
Token::LeftBracket => ASTFlags::NONE,
Token::QuestionBracket => ASTFlags::NEGATED,
_ => unreachable!(),
_ => unreachable!("`[` or `?[`"),
};
self.parse_index_chain(input, state, lib, expr, opt, true, settings.level_up())?
}
@ -1717,7 +1717,7 @@ impl Engine {
let op_flags = match op {
Token::Period => ASTFlags::NONE,
Token::Elvis => ASTFlags::NEGATED,
_ => unreachable!(),
_ => unreachable!("`.` or `?.`"),
};
Self::make_dot_expr(state, expr, rhs, ASTFlags::NONE, op_flags, tail_pos)?
}

View File

@ -248,7 +248,7 @@ impl fmt::Debug for Position {
}
#[cfg(feature = "no_position")]
unreachable!();
unreachable!("no position");
}
}
}