Skip to content

Commit

Permalink
hack for symbol name
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Feb 5, 2018
1 parent f13d8dc commit 96c3649
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ impl<'tcx> InstanceDef<'tcx> {
}
}

#[inline]
pub fn shim_def_id(&self) -> Option<DefId> {
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())
Expand Down
18 changes: 15 additions & 3 deletions src/librustc_trans_utils/symbol_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 96c3649

Please sign in to comment.