enable checking for const fn without needing to go through entry

This commit is contained in:
Oliver Schneider 2016-12-09 16:31:53 +01:00
parent acfb06fd59
commit 910c369c92
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46

View File

@ -504,6 +504,14 @@ impl<'tcx> EntryKind<'tcx> {
EntryKind::Closure(_) => return None,
})
}
fn is_const_fn(&self, meta: &CrateMetadata) -> bool {
let constness = match *self {
EntryKind::Method(data) => data.decode(meta).fn_data.constness,
EntryKind::Fn(data) => data.decode(meta).constness,
_ => hir::Constness::NotConst,
};
constness == hir::Constness::Const
}
}
impl<'a, 'tcx> CrateMetadata {
@ -1051,12 +1059,7 @@ impl<'a, 'tcx> CrateMetadata {
}
pub fn is_const_fn(&self, id: DefIndex) -> bool {
let constness = match self.entry(id).kind {
EntryKind::Method(data) => data.decode(self).fn_data.constness,
EntryKind::Fn(data) => data.decode(self).constness,
_ => hir::Constness::NotConst,
};
constness == hir::Constness::Const
self.entry(id).kind.is_const_fn(self)
}
pub fn is_foreign_item(&self, id: DefIndex) -> bool {