Skip to content

Commit 6f368e6

Browse files
Use fn_ty directly
1 parent d55e739 commit 6f368e6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/librustc_trans/callee.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
339339
// the first argument (`self`) will be the (by value) closure env.
340340

341341
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;
343345
let env_arg = &fcx.fn_ty.args[0];
344346
let llenv = if env_arg.is_indirect() {
345347
llargs[idx]
@@ -354,7 +356,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
354356
// Adjust llargs such that llargs[self_idx..] has the call arguments.
355357
// For zero-sized closures that means sneaking in a new argument.
356358
if env_arg.is_ignore() {
357-
if fcx.fn_ty.ret.is_indirect() {
359+
if fn_ty.ret.is_indirect() {
358360
llargs[0] = llenv;
359361
} else {
360362
llargs.insert(0, llenv);
@@ -366,8 +368,6 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
366368
// Call the by-ref closure body with `self` in a cleanup scope,
367369
// to drop `self` when the body returns, or in case it unwinds.
368370
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, &[]);
371371

372372
if fn_ty.ret.is_indirect() {
373373
llargs.insert(0, get_param(fcx.llfn, 0));
@@ -388,7 +388,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
388388
} else {
389389
self_scope.trans(&bcx);
390390

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() {
392392
bcx.ret_void();
393393
} else {
394394
bcx.ret(llret);
@@ -513,17 +513,15 @@ fn trans_fn_pointer_shim<'a, 'tcx>(
513513
data: Fn(llfnpointer),
514514
ty: bare_fn_ty
515515
};
516-
517516
let fn_ret = callee.ty.fn_ret();
518517
let fn_ty = callee.direct_fn_type(ccx, &[]);
519-
520518
let llret = bcx.call(llfnpointer, &llargs, None);
521519
fn_ty.apply_attrs_callsite(llret);
522520

523521
if fn_ret.0.is_never() {
524522
bcx.unreachable();
525523
} 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() {
527525
bcx.ret_void();
528526
} else {
529527
bcx.ret(llret);

0 commit comments

Comments
 (0)