Skip to content

Commit fed75b3

Browse files
committed
let_if_seq: use array_windows.
1 parent ff4e62d commit fed75b3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

clippy_lints/src/let_if_seq.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ declare_lint_pass!(LetIfSeq => [USELESS_LET_IF_SEQ]);
5858

5959
impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
6060
fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
61-
let mut it = block.stmts.iter().peekable();
62-
while let Some(stmt) = it.next() {
63-
if let Some(expr) = it.peek()
64-
&& let hir::StmtKind::Let(local) = stmt.kind
61+
for [stmt, next] in block.stmts.array_windows::<2>() {
62+
if let hir::StmtKind::Let(local) = stmt.kind
6563
&& let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind
66-
&& let hir::StmtKind::Expr(if_) = expr.kind
64+
&& let hir::StmtKind::Expr(if_) = next.kind
6765
&& let hir::ExprKind::If(
6866
hir::Expr {
6967
kind: hir::ExprKind::DropTemps(cond),

0 commit comments

Comments
 (0)