@@ -339,7 +339,9 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
339
339
// the first argument (`self`) will be the (by value) closure env.
340
340
341
341
let mut llargs = get_params ( fcx. llfn ) ;
342
- let idx = fcx. fn_ty . ret . is_indirect ( ) as usize ;
342
+ let fn_ret = callee. ty . fn_ret ( ) ;
343
+ let fn_ty = callee. direct_fn_type ( bcx. ccx , & [ ] ) ;
344
+ let idx = fn_ty. ret . is_indirect ( ) as usize ;
343
345
let env_arg = & fcx. fn_ty . args [ 0 ] ;
344
346
let llenv = if env_arg. is_indirect ( ) {
345
347
llargs[ idx]
@@ -354,7 +356,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
354
356
// Adjust llargs such that llargs[self_idx..] has the call arguments.
355
357
// For zero-sized closures that means sneaking in a new argument.
356
358
if env_arg. is_ignore ( ) {
357
- if fcx . fn_ty . ret . is_indirect ( ) {
359
+ if fn_ty. ret . is_indirect ( ) {
358
360
llargs[ 0 ] = llenv;
359
361
} else {
360
362
llargs. insert ( 0 , llenv) ;
@@ -366,8 +368,6 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
366
368
// Call the by-ref closure body with `self` in a cleanup scope,
367
369
// to drop `self` when the body returns, or in case it unwinds.
368
370
let self_scope = fcx. schedule_drop_mem ( llenv, closure_ty) ;
369
- let fn_ret = callee. ty . fn_ret ( ) ;
370
- let fn_ty = callee. direct_fn_type ( bcx. ccx , & [ ] ) ;
371
371
372
372
if fn_ty. ret . is_indirect ( ) {
373
373
llargs. insert ( 0 , get_param ( fcx. llfn , 0 ) ) ;
@@ -388,7 +388,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
388
388
} else {
389
389
self_scope. trans ( & bcx) ;
390
390
391
- if fcx . fn_ty . ret . is_indirect ( ) || fcx . fn_ty . ret . is_ignore ( ) {
391
+ if fn_ty. ret . is_indirect ( ) || fn_ty. ret . is_ignore ( ) {
392
392
bcx. ret_void ( ) ;
393
393
} else {
394
394
bcx. ret ( llret) ;
@@ -513,17 +513,15 @@ fn trans_fn_pointer_shim<'a, 'tcx>(
513
513
data : Fn ( llfnpointer) ,
514
514
ty : bare_fn_ty
515
515
} ;
516
-
517
516
let fn_ret = callee. ty . fn_ret ( ) ;
518
517
let fn_ty = callee. direct_fn_type ( ccx, & [ ] ) ;
519
-
520
518
let llret = bcx. call ( llfnpointer, & llargs, None ) ;
521
519
fn_ty. apply_attrs_callsite ( llret) ;
522
520
523
521
if fn_ret. 0 . is_never ( ) {
524
522
bcx. unreachable ( ) ;
525
523
} else {
526
- if fn_ty. ret . is_indirect ( ) || fcx . fn_ty . ret . is_ignore ( ) {
524
+ if fn_ty. ret . is_indirect ( ) || fn_ty. ret . is_ignore ( ) {
527
525
bcx. ret_void ( ) ;
528
526
} else {
529
527
bcx. ret ( llret) ;
0 commit comments