Skip to content

Commit

Permalink
Make CI green + Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
blyxyas committed Jul 3, 2024
1 parent 2eea72a commit a52281b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 3 additions & 1 deletion clippy_lints/src/loops/mut_range_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ impl<'tcx> Visitor<'tcx> for BreakAfterExprVisitor {
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) -> ControlFlow<()> {
if expr.hir_id == self.hir_id {
self.past_expr = true;
ControlFlow::Continue(())
} else if self.past_expr {
if matches!(&expr.kind, ExprKind::Break(..)) {
self.break_after_expr = true;
}

return ControlFlow::Break(());
} else {
intravisit::walk_expr(self, expr)
}
intravisit::walk_expr(self, expr)
}
}
18 changes: 6 additions & 12 deletions clippy_lints/src/unused_peekable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedPeekable {
return;
}

let mut found_peek_call = false;
let mut found_peek_call = block.stmts[idx..].iter().any(|stmt| vis.visit_stmt(stmt).is_break());

for stmt in &block.stmts[idx..] {
if vis.visit_stmt(stmt).is_break() {
found_peek_call = true;
break;
}
}

if !found_peek_call && let Some(expr) = block.expr {
if vis.visit_expr(expr).is_break() {
found_peek_call = true
}
if !found_peek_call
&& let Some(expr) = block.expr
&& vis.visit_expr(expr).is_break()
{
found_peek_call = true;
}

if !found_peek_call {
Expand Down

0 comments on commit a52281b

Please sign in to comment.