Skip to content

Commit 280069d

Browse files
committed
Auto merge of #3685 - rust-lang:rustup, r=flip1995
Rustup
2 parents 9d5b148 + d6c8063 commit 280069d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

clippy_lints/src/arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
128128
}
129129
self.const_span = Some(body_span);
130130
},
131-
hir::BodyOwnerKind::Fn => (),
131+
hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure => (),
132132
}
133133
}
134134

clippy_lints/src/utils/mod.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,25 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
6464
/// ```
6565
pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {
6666
let parent_id = cx.tcx.hir().get_parent(id);
67-
match cx.tcx.hir().body_owner_kind(parent_id) {
68-
hir::BodyOwnerKind::Fn => false,
69-
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true,
67+
match cx.tcx.hir().get(parent_id) {
68+
Node::Item(&Item {
69+
node: ItemKind::Const(..),
70+
..
71+
})
72+
| Node::TraitItem(&TraitItem {
73+
node: TraitItemKind::Const(..),
74+
..
75+
})
76+
| Node::ImplItem(&ImplItem {
77+
node: ImplItemKind::Const(..),
78+
..
79+
})
80+
| Node::AnonConst(_)
81+
| Node::Item(&Item {
82+
node: ItemKind::Static(..),
83+
..
84+
}) => true,
85+
_ => false,
7086
}
7187
}
7288

0 commit comments

Comments
 (0)