diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 63bf52a9bdf78..f208a6f286b60 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -69,6 +69,15 @@ impl<'tcx> InstanceDef<'tcx> { } } + #[inline] + pub fn shim_def_id(&self) -> Option { + if let InstanceDef::CloneShim(_, ty) = *self { + ty.ty_to_def_id() + } else { + None + } + } + #[inline] pub fn attrs<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::Attributes<'tcx> { tcx.get_attrs(self.def_id()) diff --git a/src/librustc_trans_utils/symbol_names.rs b/src/librustc_trans_utils/symbol_names.rs index fb299bf7eea0c..dd3dc5abf5b5d 100644 --- a/src/librustc_trans_utils/symbol_names.rs +++ b/src/librustc_trans_utils/symbol_names.rs @@ -226,8 +226,8 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hasher.finish() } -fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> ty::SymbolName +// The boolean is whether this is a clone shim +fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName { let mut buffer = SymbolPathBuffer::new(); item_path::with_forced_absolute_paths(|| { @@ -329,7 +329,19 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance let hash = get_symbol_hash(tcx, def_id, instance, instance_ty, substs); - SymbolPathBuffer::from_interned(tcx.def_symbol_name(def_id)).finish(hash) + let shim_id = instance.def.shim_def_id(); + + let lookup_def_id = if let Some(shim_id) = shim_id { + shim_id + } else { + def_id + }; + + let mut buf = SymbolPathBuffer::from_interned(tcx.def_symbol_name(lookup_def_id)); + if shim_id.is_some() { + buf.push("{{clone-shim}}"); + } + buf.finish(hash) } // Follow C++ namespace-mangling style, see