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