diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index efc8b139425..9c87759d51d 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1207,11 +1207,11 @@ fn find_matches_sugg(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr if b0 != b1; let if_guard = &b0_arms[0].guard; if if_guard.is_none() || b0_arms.len() == 1; - if b0_arms[0].attrs.is_empty(); + if cx.tcx.hir().attrs(b0_arms[0].hir_id).is_empty(); if b0_arms[1..].iter() .all(|arm| { find_bool_lit(&arm.body.kind, desugared).map_or(false, |b| b == b0) && - arm.guard.is_none() && arm.attrs.is_empty() + arm.guard.is_none() && cx.tcx.hir().attrs(arm.hir_id).is_empty() }); then { // The suggestion may be incorrect, because some arms can have `cfg` attributes diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 4ac15095ef5..e1c58d88952 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector { } fn check_arm(&mut self, cx: &LateContext<'tcx>, arm: &'tcx hir::Arm<'_>) { - if !has_attr(cx.sess(), &arm.attrs) { + if !has_attr(cx.sess(), cx.tcx.hir().attrs(arm.hir_id)) { return; } print_pat(cx, &arm.pat, 1);