Skip to content

Commit 824315a

Browse files
committed
Distinguish vtable shims in symbol paths.
1 parent 6fd914a commit 824315a

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/librustc_codegen_utils/symbol_names.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ fn get_symbol_hash<'a, 'tcx>(
219219
.hash_stable(&mut hcx, &mut hasher);
220220
(&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher);
221221
}
222+
223+
let is_vtable_shim = instance.is_vtable_shim();
224+
is_vtable_shim.hash_stable(&mut hcx, &mut hasher);
222225
});
223226

224227
// 64 bits should be enough to avoid collisions.
@@ -322,7 +325,13 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
322325

323326
let hash = get_symbol_hash(tcx, def_id, instance, instance_ty, substs);
324327

325-
SymbolPathBuffer::from_interned(tcx.def_symbol_name(def_id)).finish(hash)
328+
let mut buf = SymbolPathBuffer::from_interned(tcx.def_symbol_name(def_id));
329+
330+
if instance.is_vtable_shim() {
331+
buf.push("{{vtable-shim}}");
332+
}
333+
334+
buf.finish(hash)
326335
}
327336

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

src/test/ui/symbol-names/basic.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: symbol-name(_ZN5basic4main17h2138d548fb9814b6E)
1+
error: symbol-name(_ZN5basic4main17h6ab1850bb0b9f417E)
22
--> $DIR/basic.rs:13:1
33
|
44
LL | #[rustc_symbol_name] //~ ERROR _ZN5basic4main

src/test/ui/symbol-names/impl1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: symbol-name(_ZN5impl13foo3Foo3bar17h8da62e6147ff602fE)
1+
error: symbol-name(_ZN5impl13foo3Foo3bar17h99c48478d64a0eb0E)
22
--> $DIR/impl1.rs:18:9
33
|
44
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
@@ -10,7 +10,7 @@ error: item-path(foo::Foo::bar)
1010
LL | #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar)
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h374cb8f6185db9b4E)
13+
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17hebf13830acf865d9E)
1414
--> $DIR/impl1.rs:28:9
1515
|
1616
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz

0 commit comments

Comments
 (0)