Skip to content

Commit 834ed36

Browse files
authored
Rollup merge of #70003 - eddyb:symbol-mangling-reify-shims, r=nikomatsakis
symbol_names: treat ReifyShim like VtableShim. Without this, the `#[track_caller]` tests don't pass with `-Zsymbol-mangling-version=v0`, because there is a symbol name collision between the `ReifyShim` and the original definition. cc @anp
2 parents 38114ff + 14e0aad commit 834ed36

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/librustc/ty/instance.rs

-4
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,6 @@ impl<'tcx> Instance<'tcx> {
406406
| InstanceDef::VtableShim(..) => Some(self.substs),
407407
}
408408
}
409-
410-
pub fn is_vtable_shim(&self) -> bool {
411-
if let InstanceDef::VtableShim(..) = self.def { true } else { false }
412-
}
413409
}
414410

415411
fn needs_fn_once_adapter_shim(

src/librustc_symbol_mangling/legacy.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ pub(super) fn mangle(
5959
.print_def_path(def_id, &[])
6060
.unwrap();
6161

62-
if instance.is_vtable_shim() {
62+
if let ty::InstanceDef::VtableShim(..) = instance.def {
6363
let _ = printer.write_str("{{vtable-shim}}");
6464
}
6565

66+
if let ty::InstanceDef::ReifyShim(..) = instance.def {
67+
let _ = printer.write_str("{{reify-shim}}");
68+
}
69+
6670
printer.path.finish(hash)
6771
}
6872

@@ -123,7 +127,8 @@ fn get_symbol_hash<'tcx>(
123127
}
124128

125129
// We want to avoid accidental collision between different types of instances.
126-
// Especially, VtableShim may overlap with its original instance without this.
130+
// Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
131+
// instances without this.
127132
discriminant(&instance.def).hash_stable(&mut hcx, &mut hasher);
128133
});
129134

src/librustc_symbol_mangling/v0.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,17 @@ pub(super) fn mangle(
3434
binders: vec![],
3535
out: String::from(prefix),
3636
};
37-
cx = if instance.is_vtable_shim() {
38-
cx.path_append_ns(|cx| cx.print_def_path(def_id, substs), 'S', 0, "").unwrap()
37+
38+
// Append `::{shim:...#0}` to shims that can coexist with a non-shim instance.
39+
let shim_kind = match instance.def {
40+
ty::InstanceDef::VtableShim(_) => Some("vtable"),
41+
ty::InstanceDef::ReifyShim(_) => Some("reify"),
42+
43+
_ => None,
44+
};
45+
46+
cx = if let Some(shim_kind) = shim_kind {
47+
cx.path_append_ns(|cx| cx.print_def_path(def_id, substs), 'S', 0, shim_kind).unwrap()
3948
} else {
4049
cx.print_def_path(def_id, substs).unwrap()
4150
};

0 commit comments

Comments
 (0)