Skip to content

Commit 612a7fc

Browse files
committed
Add loop head span to hir
1 parent 2be935d commit 612a7fc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

clippy_lints/src/loops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops {
533533
}
534534

535535
// check for never_loop
536-
if let ExprKind::Loop(ref block, _, _) = expr.kind {
536+
if let ExprKind::Loop(ref block, _, _, _) = expr.kind {
537537
match never_loop_block(block, expr.hir_id) {
538538
NeverLoopResult::AlwaysBreak => span_lint(cx, NEVER_LOOP, expr.span, "this loop never actually loops"),
539539
NeverLoopResult::MayContinueMainLoop | NeverLoopResult::Otherwise => (),
@@ -543,7 +543,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops {
543543
// check for `loop { if let {} else break }` that could be `while let`
544544
// (also matches an explicit "match" instead of "if let")
545545
// (even if the "match" or "if let" is used for declaration)
546-
if let ExprKind::Loop(ref block, _, LoopSource::Loop) = expr.kind {
546+
if let ExprKind::Loop(ref block, _, LoopSource::Loop, _) = expr.kind {
547547
// also check for empty `loop {}` statements, skipping those in #[panic_handler]
548548
if block.stmts.is_empty() && block.expr.is_none() && !is_in_panic_handler(cx, expr) {
549549
let msg = "empty `loop {}` wastes CPU cycles";
@@ -738,7 +738,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
738738
| ExprKind::Assign(ref e1, ref e2, _)
739739
| ExprKind::AssignOp(_, ref e1, ref e2)
740740
| ExprKind::Index(ref e1, ref e2) => never_loop_expr_all(&mut [&**e1, &**e2].iter().cloned(), main_loop_id),
741-
ExprKind::Loop(ref b, _, _) => {
741+
ExprKind::Loop(ref b, _, _, _) => {
742742
// Break can come from the inner loop so remove them.
743743
absorb_break(&never_loop_block(b, main_loop_id))
744744
},
@@ -1314,7 +1314,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SameItemPushVisitor<'a, 'tcx> {
13141314
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
13151315
match &expr.kind {
13161316
// Non-determinism may occur ... don't give a lint
1317-
ExprKind::Loop(_, _, _) | ExprKind::Match(_, _, _) => self.should_lint = false,
1317+
ExprKind::Loop(..) | ExprKind::Match(..) => self.should_lint = false,
13181318
ExprKind::Block(block, _) => self.visit_block(block),
13191319
_ => {},
13201320
}

clippy_lints/src/needless_continue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ where
221221
{
222222
if let ast::ExprKind::While(_, loop_block, label)
223223
| ast::ExprKind::ForLoop(_, _, loop_block, label)
224-
| ast::ExprKind::Loop(loop_block, label) = &expr.kind
224+
| ast::ExprKind::Loop(loop_block, label, _) = &expr.kind
225225
{
226226
func(loop_block, label.as_ref());
227227
}

clippy_lints/src/shadow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
325325
| ExprKind::Field(ref e, _)
326326
| ExprKind::AddrOf(_, _, ref e)
327327
| ExprKind::Box(ref e) => check_expr(cx, e, bindings),
328-
ExprKind::Block(ref block, _) | ExprKind::Loop(ref block, _, _) => check_block(cx, block, bindings),
328+
ExprKind::Block(ref block, _) | ExprKind::Loop(ref block, ..) => check_block(cx, block, bindings),
329329
// ExprKind::Call
330330
// ExprKind::MethodCall
331331
ExprKind::Array(v) | ExprKind::Tup(v) => {

0 commit comments

Comments
 (0)