diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-01-22 14:30:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-22 14:30:19 +0000 |
| commit | e9b2cf4f6425d760df7e5e0675e8e02da11819f8 (patch) | |
| tree | 6b19c0d71d317ad420e365c6f0944be80c0262c2 /clippy_lints/src/utils/higher.rs | |
| parent | a1b89f07f00bda6d10e341fda01385f571a243b6 (diff) | |
| parent | 3a5ede6ef4b4ef6ae6c6f2c583d4c6620a95fd30 (diff) | |
Rollup merge of #81236 - estebank:everybody-loop-now, r=oli-obk
Gracefully handle loop labels missing leading `'` in different positions Fix #81192. * Account for labels when suggesting `loop` instead of `while true` * Suggest `'a` when given `a` only when appropriate * Add loop head span to hir * Tweak error for invalid `break expr` * Add more misspelled label tests * Avoid emitting redundant "unused label" lint * Parse loop labels missing a leading `'` Each commit can be reviewed in isolation.
Diffstat (limited to 'clippy_lints/src/utils/higher.rs')
| -rw-r--r-- | clippy_lints/src/utils/higher.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 9b3585865da..42ab9a1e7d2 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -142,7 +142,7 @@ pub fn for_loop<'tcx>( if let hir::ExprKind::Match(ref iterexpr, ref arms, hir::MatchSource::ForLoopDesugar) = expr.kind; if let hir::ExprKind::Call(_, ref iterargs) = iterexpr.kind; if iterargs.len() == 1 && arms.len() == 1 && arms[0].guard.is_none(); - if let hir::ExprKind::Loop(ref block, _, _) = arms[0].body.kind; + if let hir::ExprKind::Loop(ref block, ..) = arms[0].body.kind; if block.expr.is_none(); if let [ _, _, ref let_stmt, ref body ] = *block.stmts; if let hir::StmtKind::Local(ref local) = let_stmt.kind; @@ -158,7 +158,7 @@ pub fn for_loop<'tcx>( /// `while cond { body }` becomes `(cond, body)`. pub fn while_loop<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> Option<(&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>)> { if_chain! { - if let hir::ExprKind::Loop(block, _, hir::LoopSource::While) = &expr.kind; + if let hir::ExprKind::Loop(block, _, hir::LoopSource::While, _) = &expr.kind; if let hir::Block { expr: Some(expr), .. } = &**block; if let hir::ExprKind::Match(cond, arms, hir::MatchSource::WhileDesugar) = &expr.kind; if let hir::ExprKind::DropTemps(cond) = &cond.kind; |
