Include InstanceDef's discriminant in the symbol hash.
This commit is contained in:
parent
609cc26d31
commit
2075316064
3 changed files with 7 additions and 5 deletions
|
@ -114,6 +114,7 @@ use rustc_mir::monomorphize::Instance;
|
||||||
use syntax_pos::symbol::Symbol;
|
use syntax_pos::symbol::Symbol;
|
||||||
|
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
use std::mem::discriminant;
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
|
@ -220,8 +221,9 @@ fn get_symbol_hash<'a, 'tcx>(
|
||||||
(&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher);
|
(&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher);
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_vtable_shim = instance.is_vtable_shim();
|
// We want to avoid accidental collision between different types of instances.
|
||||||
is_vtable_shim.hash_stable(&mut hcx, &mut hasher);
|
// Especially, VtableShim may overlap with its original instance without this.
|
||||||
|
discriminant(&instance.def).hash_stable(&mut hcx, &mut hasher);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 64 bits should be enough to avoid collisions.
|
// 64 bits should be enough to avoid collisions.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: symbol-name(_ZN5basic4main17h6ab1850bb0b9f417E)
|
error: symbol-name(_ZN5basic4main17h08bcaf310214ed52E)
|
||||||
--> $DIR/basic.rs:13:1
|
--> $DIR/basic.rs:13:1
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name] //~ ERROR _ZN5basic4main
|
LL | #[rustc_symbol_name] //~ ERROR _ZN5basic4main
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: symbol-name(_ZN5impl13foo3Foo3bar17h99c48478d64a0eb0E)
|
error: symbol-name(_ZN5impl13foo3Foo3bar17hc487d6ec13fe9124E)
|
||||||
--> $DIR/impl1.rs:18:9
|
--> $DIR/impl1.rs:18:9
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
|
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
|
||||||
|
@ -10,7 +10,7 @@ error: item-path(foo::Foo::bar)
|
||||||
LL | #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar)
|
LL | #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar)
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17hebf13830acf865d9E)
|
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h38577281258e1527E)
|
||||||
--> $DIR/impl1.rs:28:9
|
--> $DIR/impl1.rs:28:9
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
|
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue