Skip to content

Commit 910c369

Browse files
committed
enable checking for const fn without needing to go through entry
1 parent acfb06f commit 910c369

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/librustc_metadata/decoder.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ impl<'tcx> EntryKind<'tcx> {
504504
EntryKind::Closure(_) => return None,
505505
})
506506
}
507+
fn is_const_fn(&self, meta: &CrateMetadata) -> bool {
508+
let constness = match *self {
509+
EntryKind::Method(data) => data.decode(meta).fn_data.constness,
510+
EntryKind::Fn(data) => data.decode(meta).constness,
511+
_ => hir::Constness::NotConst,
512+
};
513+
constness == hir::Constness::Const
514+
}
507515
}
508516

509517
impl<'a, 'tcx> CrateMetadata {
@@ -1051,12 +1059,7 @@ impl<'a, 'tcx> CrateMetadata {
10511059
}
10521060

10531061
pub fn is_const_fn(&self, id: DefIndex) -> bool {
1054-
let constness = match self.entry(id).kind {
1055-
EntryKind::Method(data) => data.decode(self).fn_data.constness,
1056-
EntryKind::Fn(data) => data.decode(self).constness,
1057-
_ => hir::Constness::NotConst,
1058-
};
1059-
constness == hir::Constness::Const
1062+
self.entry(id).kind.is_const_fn(self)
10601063
}
10611064

10621065
pub fn is_foreign_item(&self, id: DefIndex) -> bool {

0 commit comments

Comments
 (0)