File tree 3 files changed +26
-4
lines changed
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ pub(super) fn vtable_allocation_provider<'tcx>(
94
94
VtblEntry :: Vacant => continue ,
95
95
VtblEntry :: Method ( instance) => {
96
96
// Prepare the fn ptr we write into the vtable.
97
- let instance = instance. polymorphize ( tcx) ;
97
+ let instance = instance. cfi_shim ( tcx , invoke_trait ) . polymorphize ( tcx) ;
98
98
let fn_alloc_id = tcx. reserve_and_set_fn_alloc ( instance) ;
99
99
let fn_ptr = Pointer :: from ( fn_alloc_id) ;
100
100
Scalar :: from_pointer ( fn_ptr, & tcx)
Original file line number Diff line number Diff line change @@ -1226,9 +1226,8 @@ fn create_mono_items_for_vtable_methods<'tcx>(
1226
1226
// all super trait items already covered, so skip them.
1227
1227
None
1228
1228
}
1229
- VtblEntry :: Method ( instance) => {
1230
- Some ( * instance) . filter ( |instance| should_codegen_locally ( tcx, instance) )
1231
- }
1229
+ VtblEntry :: Method ( instance) => Some ( instance. cfi_shim ( tcx, invoke_trait) )
1230
+ . filter ( |instance| should_codegen_locally ( tcx, instance) ) ,
1232
1231
} )
1233
1232
. map ( |item| create_fn_mono_item ( tcx, item, source) ) ;
1234
1233
output. extend ( methods) ;
Original file line number Diff line number Diff line change
1
+ // Check alternate receivers work
2
+
3
+ //@ needs-sanitizer-cfi
4
+ //@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi
5
+ //@ compile-flags: -C codegen-units=1 -C opt-level=0
6
+ //@ run-pass
7
+
8
+ use std:: sync:: Arc ;
9
+
10
+ trait Fooable {
11
+ fn foo ( self : Arc < Self > ) ;
12
+ }
13
+
14
+ struct Bar ;
15
+
16
+ impl Fooable for Bar {
17
+ fn foo ( self : Arc < Self > ) { }
18
+ }
19
+
20
+ fn main ( ) {
21
+ let bar: Arc < dyn Fooable > = Arc :: new ( Bar ) ;
22
+ bar. foo ( ) ;
23
+ }
You can’t perform that action at this time.
0 commit comments