Skip to content

Commit 96c3649

Browse files
committed
hack for symbol name
1 parent f13d8dc commit 96c3649

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/librustc/ty/instance.rs

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ impl<'tcx> InstanceDef<'tcx> {
6969
}
7070
}
7171

72+
#[inline]
73+
pub fn shim_def_id(&self) -> Option<DefId> {
74+
if let InstanceDef::CloneShim(_, ty) = *self {
75+
ty.ty_to_def_id()
76+
} else {
77+
None
78+
}
79+
}
80+
7281
#[inline]
7382
pub fn attrs<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::Attributes<'tcx> {
7483
tcx.get_attrs(self.def_id())

src/librustc_trans_utils/symbol_names.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
226226
hasher.finish()
227227
}
228228

229-
fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
230-
-> ty::SymbolName
229+
// The boolean is whether this is a clone shim
230+
fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName
231231
{
232232
let mut buffer = SymbolPathBuffer::new();
233233
item_path::with_forced_absolute_paths(|| {
@@ -329,7 +329,19 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
329329

330330
let hash = get_symbol_hash(tcx, def_id, instance, instance_ty, substs);
331331

332-
SymbolPathBuffer::from_interned(tcx.def_symbol_name(def_id)).finish(hash)
332+
let shim_id = instance.def.shim_def_id();
333+
334+
let lookup_def_id = if let Some(shim_id) = shim_id {
335+
shim_id
336+
} else {
337+
def_id
338+
};
339+
340+
let mut buf = SymbolPathBuffer::from_interned(tcx.def_symbol_name(lookup_def_id));
341+
if shim_id.is_some() {
342+
buf.push("{{clone-shim}}");
343+
}
344+
buf.finish(hash)
333345
}
334346

335347
// Follow C++ namespace-mangling style, see

0 commit comments

Comments
 (0)