1
Fork 0

ensure we intern all promoteds as InternKind::Promoted

This commit is contained in:
Ralf Jung 2020-10-24 17:23:45 +02:00
parent 1cd97cad6e
commit d0a23e613d

View file

@ -59,16 +59,13 @@ fn eval_body_using_ecx<'mir, 'tcx>(
ecx.run()?; ecx.run()?;
// Intern the result // Intern the result
// FIXME: since the DefId of a promoted is the DefId of its owner, this let intern_kind = if cid.promoted.is_some() {
// means that promoteds in statics are actually interned like statics! InternKind::Promoted
// However, this is also currently crucial because we promote mutable } else {
// non-empty slices in statics to extend their lifetime, and this match tcx.static_mutability(cid.instance.def_id()) {
// ensures that they are put into a mutable allocation.
// For other kinds of promoteds in statics (like array initializers), this is rather silly.
let intern_kind = match tcx.static_mutability(cid.instance.def_id()) {
Some(m) => InternKind::Static(m), Some(m) => InternKind::Static(m),
None if cid.promoted.is_some() => InternKind::Promoted, None => InternKind::Constant,
_ => InternKind::Constant, }
}; };
intern_const_alloc_recursive( intern_const_alloc_recursive(
ecx, ecx,