16
16
17
17
pub use self :: CalleeData :: * ;
18
18
19
- use llvm:: { self , ValueRef , get_param , get_params} ;
19
+ use llvm:: { self , ValueRef , get_params} ;
20
20
use rustc:: hir:: def_id:: DefId ;
21
21
use rustc:: ty:: subst:: Substs ;
22
22
use rustc:: traits;
@@ -342,13 +342,13 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
342
342
let mut llargs = get_params ( fcx. llfn ) ;
343
343
let fn_ret = callee. ty . fn_ret ( ) ;
344
344
let fn_ty = callee. direct_fn_type ( bcx. ccx , & [ ] ) ;
345
- let idx = fn_ty. ret . is_indirect ( ) as usize ;
345
+ let self_idx = fn_ty. ret . is_indirect ( ) as usize ;
346
346
let env_arg = & orig_fn_ty. args [ 0 ] ;
347
347
let llenv = if env_arg. is_indirect ( ) {
348
- llargs[ idx ]
348
+ llargs[ self_idx ]
349
349
} else {
350
350
let scratch = alloc_ty ( & bcx, closure_ty, "self" ) ;
351
- let mut llarg_idx = idx ;
351
+ let mut llarg_idx = self_idx ;
352
352
env_arg. store_fn_arg ( & bcx, & mut llarg_idx, scratch) ;
353
353
scratch
354
354
} ;
@@ -357,22 +357,15 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
357
357
// Adjust llargs such that llargs[self_idx..] has the call arguments.
358
358
// For zero-sized closures that means sneaking in a new argument.
359
359
if env_arg. is_ignore ( ) {
360
- if fn_ty. ret . is_indirect ( ) {
361
- llargs[ 0 ] = llenv;
362
- } else {
363
- llargs. insert ( 0 , llenv) ;
364
- }
360
+ llargs. insert ( self_idx, llenv) ;
365
361
} else {
366
- llargs[ idx ] = llenv;
362
+ llargs[ self_idx ] = llenv;
367
363
}
368
364
369
365
// Call the by-ref closure body with `self` in a cleanup scope,
370
366
// to drop `self` when the body returns, or in case it unwinds.
371
367
let self_scope = fcx. schedule_drop_mem ( llenv, closure_ty) ;
372
368
373
- if fn_ty. ret . is_indirect ( ) {
374
- llargs. insert ( 0 , get_param ( fcx. llfn , 0 ) ) ;
375
- }
376
369
let llfn = callee. reify ( bcx. ccx ) ;
377
370
let llret;
378
371
if let Some ( landing_pad) = self_scope. landing_pad {
0 commit comments