Clean up unnecessary unwraps

This commit is contained in:
F3real 2021-07-23 17:30:27 +02:00
parent c3452f3bd2
commit 045dbb52d5

View File

@ -370,15 +370,14 @@ fn suggestion_snippet_for_continue_inside_else<'a>(cx: &EarlyContext<'_>, data:
fn check_and_warn<'a>(cx: &EarlyContext<'_>, expr: &'a ast::Expr) { fn check_and_warn<'a>(cx: &EarlyContext<'_>, expr: &'a ast::Expr) {
if_chain! { if_chain! {
if let ast::ExprKind::Loop(loop_block, ..) = &expr.kind; if let ast::ExprKind::Loop(loop_block, ..) = &expr.kind;
if !loop_block.stmts.is_empty(); if let Some(last_stmt) = loop_block.stmts.last();
if let ast::StmtKind::Expr(ref statement) if let ast::StmtKind::Expr(inner_expr) | ast::StmtKind::Semi(inner_expr) = &last_stmt.kind;
| ast::StmtKind::Semi(ref statement) = loop_block.stmts.last().unwrap().kind; if let ast::ExprKind::Continue(_) = inner_expr.kind;
if let ast::ExprKind::Continue(_) = statement.kind;
then { then {
span_lint_and_help( span_lint_and_help(
cx, cx,
NEEDLESS_CONTINUE, NEEDLESS_CONTINUE,
loop_block.stmts.last().unwrap().span, last_stmt.span,
MSG_REDUNDANT_CONTINUE_EXPRESSION, MSG_REDUNDANT_CONTINUE_EXPRESSION,
None, None,
DROP_CONTINUE_EXPRESSION_MSG, DROP_CONTINUE_EXPRESSION_MSG,