Auto merge of #3685 - rust-lang:rustup, r=flip1995

Rustup
This commit is contained in:
bors 2019-01-22 16:07:32 +00:00
commit 280069ddc7
2 changed files with 20 additions and 4 deletions

View File

@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
} }
self.const_span = Some(body_span); self.const_span = Some(body_span);
}, },
hir::BodyOwnerKind::Fn => (), hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure => (),
} }
} }

View File

@ -64,9 +64,25 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
/// ``` /// ```
pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool { pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {
let parent_id = cx.tcx.hir().get_parent(id); let parent_id = cx.tcx.hir().get_parent(id);
match cx.tcx.hir().body_owner_kind(parent_id) { match cx.tcx.hir().get(parent_id) {
hir::BodyOwnerKind::Fn => false, Node::Item(&Item {
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true, node: ItemKind::Const(..),
..
})
| Node::TraitItem(&TraitItem {
node: TraitItemKind::Const(..),
..
})
| Node::ImplItem(&ImplItem {
node: ImplItemKind::Const(..),
..
})
| Node::AnonConst(_)
| Node::Item(&Item {
node: ItemKind::Static(..),
..
}) => true,
_ => false,
} }
} }