We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3168023 commit 38cdf63Copy full SHA for 38cdf63
clippy_lints/src/utils/mod.rs
@@ -64,9 +64,14 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
64
/// ```
65
pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {
66
let parent_id = cx.tcx.hir().get_parent(id);
67
- match cx.tcx.hir().body_owner_kind(parent_id) {
68
- hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure => false,
69
- hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true,
+ match cx.tcx.hir().get(parent_id) {
+ | Node::Item(&Item { node: ItemKind::Const(..), .. })
+ | Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. })
70
+ | Node::ImplItem(&ImplItem { node: ImplItemKind::Const(..), .. })
71
+ | Node::AnonConst(_)
72
+ | Node::Item(&Item { node: ItemKind::Static(..), .. })
73
+ => true,
74
+ _ => false,
75
}
76
77
0 commit comments