about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2024-06-12 23:17:08 -0400
committerJason Newcomb <jsnewcomb@pm.me>2024-07-07 18:05:51 -0400
commitfed75b3895397a72dfd881e44f432dd9624a76ce (patch)
treea998e2ec165125f1745d689969ad4cf3081c0649
parentff4e62d3ec08e7243f8085e60d72f296f8373812 (diff)
downloadrust-fed75b3895397a72dfd881e44f432dd9624a76ce.tar.gz
rust-fed75b3895397a72dfd881e44f432dd9624a76ce.zip
`let_if_seq`: use `array_windows`.
-rw-r--r--clippy_lints/src/let_if_seq.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs
index a65cb3f4dfb..0e488cee6b7 100644
--- a/clippy_lints/src/let_if_seq.rs
+++ b/clippy_lints/src/let_if_seq.rs
@@ -58,12 +58,10 @@ declare_lint_pass!(LetIfSeq => [USELESS_LET_IF_SEQ]);
 
 impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
     fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
-        let mut it = block.stmts.iter().peekable();
-        while let Some(stmt) = it.next() {
-            if let Some(expr) = it.peek()
-                && let hir::StmtKind::Let(local) = stmt.kind
+        for [stmt, next] in block.stmts.array_windows::<2>() {
+            if let hir::StmtKind::Let(local) = stmt.kind
                 && let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind
-                && let hir::StmtKind::Expr(if_) = expr.kind
+                && let hir::StmtKind::Expr(if_) = next.kind
                 && let hir::ExprKind::If(
                     hir::Expr {
                         kind: hir::ExprKind::DropTemps(cond),