diff options
| author | Ralf Jung <post@ralfj.de> | 2020-10-24 17:23:45 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-10-26 08:56:54 +0100 |
| commit | d0a23e613d7b932ee7e29489afce15580fa5cb66 (patch) | |
| tree | 74f1af2017bc8c6279f727ec5e1a8d2ddead4d3a | |
| parent | 1cd97cad6e5f85bed455f505f330ead1d5cd8432 (diff) | |
ensure we intern all promoteds as InternKind::Promoted
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/eval_queries.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/rustc_mir/src/const_eval/eval_queries.rs b/compiler/rustc_mir/src/const_eval/eval_queries.rs index 6ef73b04238..2c92c8e2a68 100644 --- a/compiler/rustc_mir/src/const_eval/eval_queries.rs +++ b/compiler/rustc_mir/src/const_eval/eval_queries.rs @@ -59,16 +59,13 @@ fn eval_body_using_ecx<'mir, 'tcx>( ecx.run()?; // Intern the result - // FIXME: since the DefId of a promoted is the DefId of its owner, this - // means that promoteds in statics are actually interned like statics! - // However, this is also currently crucial because we promote mutable - // non-empty slices in statics to extend their lifetime, and this - // 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), - None if cid.promoted.is_some() => InternKind::Promoted, - _ => InternKind::Constant, + let intern_kind = if cid.promoted.is_some() { + InternKind::Promoted + } else { + match tcx.static_mutability(cid.instance.def_id()) { + Some(m) => InternKind::Static(m), + None => InternKind::Constant, + } }; intern_const_alloc_recursive( ecx, |
