Skip to content

Commit 778ddff

Browse files
committed
ensure we intern all promoteds as InternKind::Promoted
1 parent d8ec83f commit 778ddff

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

compiler/rustc_mir/src/const_eval/eval_queries.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,13 @@ fn eval_body_using_ecx<'mir, 'tcx>(
5959
ecx.run()?;
6060

6161
// Intern the result
62-
// FIXME: since the DefId of a promoted is the DefId of its owner, this
63-
// means that promoteds in statics are actually interned like statics!
64-
// However, this is also currently crucial because we promote mutable
65-
// non-empty slices in statics to extend their lifetime, and this
66-
// ensures that they are put into a mutable allocation.
67-
// For other kinds of promoteds in statics (like array initializers), this is rather silly.
68-
let intern_kind = match tcx.static_mutability(cid.instance.def_id()) {
69-
Some(m) => InternKind::Static(m),
70-
None if cid.promoted.is_some() => InternKind::Promoted,
71-
_ => InternKind::Constant,
62+
let intern_kind = if cid.promoted.is_some() {
63+
InternKind::Promoted
64+
} else {
65+
match tcx.static_mutability(cid.instance.def_id()) {
66+
Some(m) => InternKind::Static(m),
67+
None => InternKind::Constant,
68+
}
7269
};
7370
intern_const_alloc_recursive(
7471
ecx,

0 commit comments

Comments
 (0)