Skip to content

Commit 06f83b4

Browse files
committed
index_refutable_slice: Check HIR tree first.
1 parent b58b491 commit 06f83b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/index_refutable_slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ impl_lint_pass!(IndexRefutableSlice => [INDEX_REFUTABLE_SLICE]);
7070

7171
impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
7272
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
73-
if (!expr.span.from_expansion() || is_expn_of(expr.span, "if_chain").is_some())
74-
&& let Some(IfLet { let_pat, if_then, .. }) = IfLet::hir(cx, expr)
73+
if let Some(IfLet { let_pat, if_then, .. }) = IfLet::hir(cx, expr)
74+
&& (!expr.span.from_expansion() || is_expn_of(expr.span, "if_chain").is_some())
7575
&& !is_lint_allowed(cx, INDEX_REFUTABLE_SLICE, expr.hir_id)
7676
&& self.msrv.meets(msrvs::SLICE_PATTERNS)
7777
&& let found_slices = find_slice_values(cx, let_pat)

0 commit comments

Comments
 (0)