File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ use rustc_mir::monomorphize::Instance;
114114use syntax_pos:: symbol:: Symbol ;
115115
116116use std:: fmt:: Write ;
117+ use std:: mem:: discriminant;
117118
118119pub fn provide ( providers : & mut Providers ) {
119120 * providers = Providers {
@@ -220,8 +221,9 @@ fn get_symbol_hash<'a, 'tcx>(
220221 ( & tcx. crate_disambiguator ( instantiating_crate) ) . hash_stable ( & mut hcx, & mut hasher) ;
221222 }
222223
223- let is_vtable_shim = instance. is_vtable_shim ( ) ;
224- is_vtable_shim. hash_stable ( & mut hcx, & mut hasher) ;
224+ // We want to avoid accidental collision between different types of instances.
225+ // Especially, VtableShim may overlap with its original instance without this.
226+ discriminant ( & instance. def ) . hash_stable ( & mut hcx, & mut hasher) ;
225227 } ) ;
226228
227229 // 64 bits should be enough to avoid collisions.
Original file line number Diff line number Diff line change 1- error: symbol-name(_ZN5basic4main17h6ab1850bb0b9f417E )
1+ error: symbol-name(_ZN5basic4main17h08bcaf310214ed52E )
22 --> $DIR/basic.rs:13:1
33 |
44LL | #[rustc_symbol_name] //~ ERROR _ZN5basic4main
Original file line number Diff line number Diff line change 1- error: symbol-name(_ZN5impl13foo3Foo3bar17h99c48478d64a0eb0E )
1+ error: symbol-name(_ZN5impl13foo3Foo3bar17hc487d6ec13fe9124E )
22 --> $DIR/impl1.rs:18:9
33 |
44LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
@@ -10,7 +10,7 @@ error: item-path(foo::Foo::bar)
1010LL | #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar)
1111 | ^^^^^^^^^^^^^^^^^^
1212
13- error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17hebf13830acf865d9E )
13+ error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h38577281258e1527E )
1414 --> $DIR/impl1.rs:28:9
1515 |
1616LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
You can’t perform that action at this time.
0 commit comments