From f45906d2325848a42e8330fbcd8c01439a88ad01 Mon Sep 17 00:00:00 2001 From: Amanjeev Sethi Date: Fri, 22 Jul 2022 14:08:44 -0400 Subject: [PATCH] lifetime was missing, elided to actually compile --- compiler/rustc_codegen_llvm/src/common.rs | 7 ++++--- compiler/rustc_codegen_llvm/src/consts.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index 2c0df011de981..788b2b554e6d6 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -11,7 +11,7 @@ use rustc_ast::Mutability; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::*; use rustc_middle::bug; -use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; +use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar, StaticAllocation}; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::ScalarInt; use rustc_span::symbol::Symbol; @@ -242,8 +242,9 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { GlobalAlloc::Memory(alloc) => { let init = const_alloc_to_llvm(self, alloc); let alloc = alloc.inner(); - let name = alloc.extra.map(|(item, idx)| { - let item_name = self.get_static_name(item); + let name = alloc.extra.map(|salloc: StaticAllocation| { + let item_name = self.get_static_name(salloc.item); + let idx = salloc.local_index; format!("{item_name}[{idx}]") }); let name = name.as_deref(); diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index d19e2cfc0bdfc..8eb121358a3b3 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -241,7 +241,7 @@ impl<'ll> CodegenCx<'ll, '_> { } } - crate fn get_static_name(&self, def_id: DefId) -> &'tcx str { + crate fn get_static_name(&self, def_id: DefId) -> &'_ str { let instance = Instance::mono(self.tcx, def_id); self.tcx.symbol_name(instance).name }