@@ -43,8 +43,14 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
43
43
let mut result = match instance {
44
44
ty:: InstanceDef :: Item ( ..) =>
45
45
bug ! ( "item {:?} passed to make_shim" , instance) ,
46
- ty:: InstanceDef :: VtableShim ( ..) => {
47
- unimplemented ! ( "make_shim({:?})" , instance) ;
46
+ ty:: InstanceDef :: VtableShim ( def_id) => {
47
+ build_call_shim (
48
+ tcx,
49
+ def_id,
50
+ Adjustment :: DerefMove ,
51
+ CallKind :: Direct ( def_id) ,
52
+ None ,
53
+ )
48
54
}
49
55
ty:: InstanceDef :: FnPtrShim ( def_id, ty) => {
50
56
let trait_ = tcx. trait_of_item ( def_id) . unwrap ( ) ;
@@ -131,6 +137,7 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
131
137
enum Adjustment {
132
138
Identity ,
133
139
Deref ,
140
+ DerefMove ,
134
141
RefMut ,
135
142
}
136
143
@@ -704,6 +711,14 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
704
711
let rcvr = match rcvr_adjustment {
705
712
Adjustment :: Identity => Operand :: Move ( rcvr_l) ,
706
713
Adjustment :: Deref => Operand :: Copy ( rcvr_l. deref ( ) ) ,
714
+ Adjustment :: DerefMove => {
715
+ // fn(Self, ...) -> fn(*mut Self, ...)
716
+ let arg_ty = local_decls[ rcvr_arg] . ty ;
717
+ assert ! ( arg_ty. is_self( ) ) ;
718
+ local_decls[ rcvr_arg] . ty = tcx. mk_mut_ptr ( arg_ty) ;
719
+
720
+ Operand :: Copy ( rcvr_l. deref ( ) )
721
+ }
707
722
Adjustment :: RefMut => {
708
723
// let rcvr = &mut rcvr;
709
724
let ref_rcvr = local_decls. push ( temp_decl (
0 commit comments