Skip to content

Commit e2bbf06

Browse files
committed
Explain why "loading" constness from extern crates does not necessarily load anything
1 parent d9cca74 commit e2bbf06

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc_metadata/rmeta/decoder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1360,11 +1360,15 @@ impl<'a, 'tcx> CrateMetadata {
13601360
}
13611361
}
13621362

1363+
// This replicates some of the logic of the crate-local `is_const_fn_raw` query, because we
1364+
// don't serialize constness for tuple variant and tuple struct constructors.
13631365
fn is_const_fn_raw(&self, id: DefIndex) -> bool {
13641366
let constness = match self.kind(id) {
13651367
EntryKind::Method(data) => data.decode(self).fn_data.constness,
13661368
EntryKind::Fn(data) => data.decode(self).constness,
1367-
// Some intrinsics can be const fn
1369+
// Some intrinsics can be const fn. While we could recompute this (at least until we
1370+
// stop having hardcoded whitelists and move to stability attributes), it seems cleaner
1371+
// to treat all const fns equally.
13681372
EntryKind::ForeignFn(data) => data.decode(self).constness,
13691373
EntryKind::Variant(..) | EntryKind::Struct(..) => hir::Constness::Const,
13701374
_ => hir::Constness::NotConst,

0 commit comments

Comments
 (0)