@@ -62,12 +62,24 @@ impl<'tcx> Instance<'tcx> {
62
62
)
63
63
}
64
64
65
- fn fn_sig_noadjust ( & self , tcx : TyCtxt < ' tcx > ) -> PolyFnSig < ' tcx > {
65
+ pub fn fn_sig ( & self , tcx : TyCtxt < ' tcx > ) -> PolyFnSig < ' tcx > {
66
66
let ty = self . ty ( tcx) ;
67
67
match ty. kind {
68
68
ty:: FnDef ( ..) |
69
69
// Shims currently have type FnPtr. Not sure this should remain.
70
- ty:: FnPtr ( _) => ty. fn_sig ( tcx) ,
70
+ ty:: FnPtr ( _) => {
71
+ let mut sig = ty. fn_sig ( tcx) ;
72
+ if let InstanceDef :: VtableShim ( ..) = self . def {
73
+ // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`.
74
+ sig = sig. map_bound ( |mut sig| {
75
+ let mut inputs_and_output = sig. inputs_and_output . to_vec ( ) ;
76
+ inputs_and_output[ 0 ] = tcx. mk_mut_ptr ( inputs_and_output[ 0 ] ) ;
77
+ sig. inputs_and_output = tcx. intern_type_list ( & inputs_and_output) ;
78
+ sig
79
+ } ) ;
80
+ }
81
+ sig
82
+ }
71
83
ty:: Closure ( def_id, substs) => {
72
84
let sig = substs. as_closure ( ) . sig ( def_id, tcx) ;
73
85
@@ -108,22 +120,8 @@ impl<'tcx> Instance<'tcx> {
108
120
)
109
121
} )
110
122
}
111
- _ => bug ! ( "unexpected type {:?} in Instance::fn_sig_noadjust" , ty)
112
- }
113
- }
114
-
115
- pub fn fn_sig ( & self , tcx : TyCtxt < ' tcx > ) -> ty:: PolyFnSig < ' tcx > {
116
- let mut fn_sig = self . fn_sig_noadjust ( tcx) ;
117
- if let InstanceDef :: VtableShim ( ..) = self . def {
118
- // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`.
119
- fn_sig = fn_sig. map_bound ( |mut fn_sig| {
120
- let mut inputs_and_output = fn_sig. inputs_and_output . to_vec ( ) ;
121
- inputs_and_output[ 0 ] = tcx. mk_mut_ptr ( inputs_and_output[ 0 ] ) ;
122
- fn_sig. inputs_and_output = tcx. intern_type_list ( & inputs_and_output) ;
123
- fn_sig
124
- } ) ;
123
+ _ => bug ! ( "unexpected type {:?} in Instance::fn_sig" , ty)
125
124
}
126
- fn_sig
127
125
}
128
126
}
129
127
0 commit comments