Skip to content

Commit 045dbb5

Browse files
committed
Clean up unnecessary unwraps
1 parent c3452f3 commit 045dbb5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

clippy_lints/src/needless_continue.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,14 @@ fn suggestion_snippet_for_continue_inside_else<'a>(cx: &EarlyContext<'_>, data:
370370
fn check_and_warn<'a>(cx: &EarlyContext<'_>, expr: &'a ast::Expr) {
371371
if_chain! {
372372
if let ast::ExprKind::Loop(loop_block, ..) = &expr.kind;
373-
if !loop_block.stmts.is_empty();
374-
if let ast::StmtKind::Expr(ref statement)
375-
| ast::StmtKind::Semi(ref statement) = loop_block.stmts.last().unwrap().kind;
376-
if let ast::ExprKind::Continue(_) = statement.kind;
373+
if let Some(last_stmt) = loop_block.stmts.last();
374+
if let ast::StmtKind::Expr(inner_expr) | ast::StmtKind::Semi(inner_expr) = &last_stmt.kind;
375+
if let ast::ExprKind::Continue(_) = inner_expr.kind;
377376
then {
378377
span_lint_and_help(
379378
cx,
380379
NEEDLESS_CONTINUE,
381-
loop_block.stmts.last().unwrap().span,
380+
last_stmt.span,
382381
MSG_REDUNDANT_CONTINUE_EXPRESSION,
383382
None,
384383
DROP_CONTINUE_EXPRESSION_MSG,

0 commit comments

Comments
 (0)