@@ -78,11 +78,11 @@ impl AllocFnFactory<'_, '_> {
78
78
} ;
79
79
let args = method. inputs . iter ( ) . map ( |ty| self . arg_ty ( ty, & mut abi_args, & mut mk) ) . collect ( ) ;
80
80
let result = self . call_allocator ( method. name , args) ;
81
- let ( output_ty, output_expr ) = self . ret_ty ( & method. output , result ) ;
81
+ let output_ty = self . ret_ty ( & method. output ) ;
82
82
let decl = self . cx . fn_decl ( abi_args, ast:: FnRetTy :: Ty ( output_ty) ) ;
83
83
let header = FnHeader { unsafety : Unsafe :: Yes ( self . span ) , ..FnHeader :: default ( ) } ;
84
84
let sig = FnSig { decl, header, span : self . span } ;
85
- let body = Some ( self . cx . block_expr ( output_expr ) ) ;
85
+ let body = Some ( self . cx . block_expr ( result ) ) ;
86
86
let kind = ItemKind :: Fn ( Box :: new ( Fn {
87
87
defaultness : ast:: Defaultness :: Final ,
88
88
sig,
@@ -140,8 +140,7 @@ impl AllocFnFactory<'_, '_> {
140
140
AllocatorTy :: Ptr => {
141
141
let ident = ident ( ) ;
142
142
args. push ( self . cx . param ( self . span , ident, self . ptr_u8 ( ) ) ) ;
143
- let arg = self . cx . expr_ident ( self . span , ident) ;
144
- self . cx . expr_cast ( self . span , arg, self . ptr_u8 ( ) )
143
+ self . cx . expr_ident ( self . span , ident)
145
144
}
146
145
147
146
AllocatorTy :: Usize => {
@@ -156,18 +155,11 @@ impl AllocFnFactory<'_, '_> {
156
155
}
157
156
}
158
157
159
- fn ret_ty ( & self , ty : & AllocatorTy , expr : P < Expr > ) -> ( P < Ty > , P < Expr > ) {
158
+ fn ret_ty ( & self , ty : & AllocatorTy ) -> P < Ty > {
160
159
match * ty {
161
- AllocatorTy :: ResultPtr => {
162
- // We're creating:
163
- //
164
- // #expr as *mut u8
165
-
166
- let expr = self . cx . expr_cast ( self . span , expr, self . ptr_u8 ( ) ) ;
167
- ( self . ptr_u8 ( ) , expr)
168
- }
160
+ AllocatorTy :: ResultPtr => self . ptr_u8 ( ) ,
169
161
170
- AllocatorTy :: Unit => ( self . cx . ty ( self . span , TyKind :: Tup ( ThinVec :: new ( ) ) ) , expr ) ,
162
+ AllocatorTy :: Unit => self . cx . ty ( self . span , TyKind :: Tup ( ThinVec :: new ( ) ) ) ,
171
163
172
164
AllocatorTy :: Layout | AllocatorTy :: Usize | AllocatorTy :: Ptr => {
173
165
panic ! ( "can't convert `AllocatorTy` to an output" )
0 commit comments