@@ -10,7 +10,7 @@ use rustc_ast::{LitKind, RangeLimits};
1010use rustc_data_structures:: packed:: Pu128 ;
1111use rustc_data_structures:: unhash:: UnhashMap ;
1212use rustc_errors:: { Applicability , Diag } ;
13- use rustc_hir:: { BinOp , Block , Body , Expr , ExprKind , UnOp } ;
13+ use rustc_hir:: { BinOp , Block , Body , Expr , ExprKind , UnOp , StmtKind } ;
1414use rustc_lint:: { LateContext , LateLintPass } ;
1515use rustc_session:: declare_lint_pass;
1616use rustc_span:: source_map:: Spanned ;
@@ -136,6 +136,10 @@ fn assert_len_expr<'hir>(
136136) -> Option < ( LengthComparison , usize , & ' hir Expr < ' hir > ) > {
137137 if let Some ( higher:: If { cond, then, .. } ) = higher:: If :: hir ( expr)
138138 && let ExprKind :: Unary ( UnOp :: Not , condition) = & cond. kind
139+ && let ExprKind :: Block ( block, None ) = condition. kind
140+ && let [ local] = block. stmts
141+ && let StmtKind :: Let ( local) = local. kind
142+ && let Some ( condition) = local. init
139143 && let ExprKind :: Binary ( bin_op, left, right) = & condition. kind
140144
141145 && let Some ( ( cmp, asserted_len, slice_len) ) = len_comparison ( * bin_op, left, right)
0 commit comments