File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 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>(
9494 VtblEntry :: Vacant => continue ,
9595 VtblEntry :: Method ( instance) => {
9696 // 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) ;
9898 let fn_alloc_id = tcx. reserve_and_set_fn_alloc ( instance) ;
9999 let fn_ptr = Pointer :: from ( fn_alloc_id) ;
100100 Scalar :: from_pointer ( fn_ptr, & tcx)
Original file line number Diff line number Diff line change @@ -1213,9 +1213,8 @@ fn create_mono_items_for_vtable_methods<'tcx>(
12131213 // all super trait items already covered, so skip them.
12141214 None
12151215 }
1216- VtblEntry :: Method ( instance) => {
1217- Some ( * instance) . filter ( |instance| should_codegen_locally ( tcx, instance) )
1218- }
1216+ VtblEntry :: Method ( instance) => Some ( instance. cfi_shim ( tcx, invoke_trait) )
1217+ . filter ( |instance| should_codegen_locally ( tcx, instance) ) ,
12191218 } )
12201219 . map ( |item| create_fn_mono_item ( tcx, item, source) ) ;
12211220 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