diff options
| author | F3real <stefan92ff@yandex.com> | 2021-07-23 17:30:27 +0200 |
|---|---|---|
| committer | F3real <stefan92ff@yandex.com> | 2021-07-23 17:34:27 +0200 |
| commit | 045dbb52d5bc3d97d30234c69a9c556f7d779732 (patch) | |
| tree | 2bac2f1801c6e5d1688f98f14b9d258e8ef9a6f3 | |
| parent | c3452f3bd261e029b361c94ba8ed3bb909fde5fb (diff) | |
| download | rust-045dbb52d5bc3d97d30234c69a9c556f7d779732.tar.gz rust-045dbb52d5bc3d97d30234c69a9c556f7d779732.zip | |
Clean up unnecessary unwraps
| -rw-r--r-- | clippy_lints/src/needless_continue.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index a1f224e7d3a..1d19413e0d0 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -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) { if_chain! { if let ast::ExprKind::Loop(loop_block, ..) = &expr.kind; - if !loop_block.stmts.is_empty(); - if let ast::StmtKind::Expr(ref statement) - | ast::StmtKind::Semi(ref statement) = loop_block.stmts.last().unwrap().kind; - if let ast::ExprKind::Continue(_) = statement.kind; + if let Some(last_stmt) = loop_block.stmts.last(); + if let ast::StmtKind::Expr(inner_expr) | ast::StmtKind::Semi(inner_expr) = &last_stmt.kind; + if let ast::ExprKind::Continue(_) = inner_expr.kind; then { span_lint_and_help( cx, NEEDLESS_CONTINUE, - loop_block.stmts.last().unwrap().span, + last_stmt.span, MSG_REDUNDANT_CONTINUE_EXPRESSION, None, DROP_CONTINUE_EXPRESSION_MSG, |
