This commit is contained in:
Oliver Schneider
2017-11-15 08:38:43 +01:00
parent b464432972
commit c6a4eaeb0d
4 changed files with 9 additions and 7 deletions

View File

@@ -9,7 +9,6 @@ use rustc::lint::{LateContext, Level, Lint, LintContext};
use rustc::session::Session;
use rustc::traits;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::mir::transform::MirSource;
use rustc_errors;
use std::borrow::Cow;
use std::env;
@@ -48,9 +47,9 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
pub fn in_constant(cx: &LateContext, id: NodeId) -> bool {
let parent_id = cx.tcx.hir.get_parent(id);
match MirSource::from_node(cx.tcx, parent_id) {
MirSource::GeneratorDrop(_) | MirSource::Fn(_) => false,
MirSource::Const(_) | MirSource::Static(..) | MirSource::Promoted(..) => true,
match cx.tcx.hir.body_owner_kind(parent_id) {
hir::BodyOwnerKind::Fn => false,
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true,
}
}