symbol_names: treat ReifyShim like VtableShim.

This commit is contained in:
Eduard-Mihai Burtescu
2020-03-14 18:48:10 +02:00
parent 98803c182b
commit 14e0aad990
3 changed files with 18 additions and 8 deletions
-4
View File
@@ -406,10 +406,6 @@ pub fn substs_for_mir_body(&self) -> Option<SubstsRef<'tcx>> {
| InstanceDef::VtableShim(..) => Some(self.substs),
}
}
pub fn is_vtable_shim(&self) -> bool {
if let InstanceDef::VtableShim(..) = self.def { true } else { false }
}
}
fn needs_fn_once_adapter_shim(
+7 -2
View File
@@ -59,10 +59,14 @@ pub(super) fn mangle(
.print_def_path(def_id, &[])
.unwrap();
if instance.is_vtable_shim() {
if let ty::InstanceDef::VtableShim(..) = instance.def {
let _ = printer.write_str("{{vtable-shim}}");
}
if let ty::InstanceDef::ReifyShim(..) = instance.def {
let _ = printer.write_str("{{reify-shim}}");
}
printer.path.finish(hash)
}
@@ -123,7 +127,8 @@ fn get_symbol_hash<'tcx>(
}
// We want to avoid accidental collision between different types of instances.
// Especially, VtableShim may overlap with its original instance without this.
// Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
// instances without this.
discriminant(&instance.def).hash_stable(&mut hcx, &mut hasher);
});
+11 -2
View File
@@ -34,8 +34,17 @@ pub(super) fn mangle(
binders: vec![],
out: String::from(prefix),
};
cx = if instance.is_vtable_shim() {
cx.path_append_ns(|cx| cx.print_def_path(def_id, substs), 'S', 0, "").unwrap()
// Append `::{shim:...#0}` to shims that can coexist with a non-shim instance.
let shim_kind = match instance.def {
ty::InstanceDef::VtableShim(_) => Some("vtable"),
ty::InstanceDef::ReifyShim(_) => Some("reify"),
_ => None,
};
cx = if let Some(shim_kind) = shim_kind {
cx.path_append_ns(|cx| cx.print_def_path(def_id, substs), 'S', 0, shim_kind).unwrap()
} else {
cx.print_def_path(def_id, substs).unwrap()
};