@@ -62,12 +62,24 @@ impl<'tcx> Instance<'tcx> {
6262 )
6363 }
6464
65- fn fn_sig_noadjust ( & self , tcx : TyCtxt < ' tcx > ) -> PolyFnSig < ' tcx > {
65+ pub fn fn_sig ( & self , tcx : TyCtxt < ' tcx > ) -> PolyFnSig < ' tcx > {
6666 let ty = self . ty ( tcx) ;
6767 match ty. kind {
6868 ty:: FnDef ( ..) |
6969 // 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+ }
7183 ty:: Closure ( def_id, substs) => {
7284 let sig = substs. as_closure ( ) . sig ( def_id, tcx) ;
7385
@@ -108,22 +120,8 @@ impl<'tcx> Instance<'tcx> {
108120 )
109121 } )
110122 }
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)
125124 }
126- fn_sig
127125 }
128126}
129127
0 commit comments