Skip to content

Commit 07cf2a9

Browse files
Simplify callee by removing is_indirect branch.
1 parent 57914f6 commit 07cf2a9

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/librustc_trans/callee.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
pub use self::CalleeData::*;
1818

19-
use llvm::{self, ValueRef, get_param, get_params};
19+
use llvm::{self, ValueRef, get_params};
2020
use rustc::hir::def_id::DefId;
2121
use rustc::ty::subst::Substs;
2222
use rustc::traits;
@@ -342,13 +342,13 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
342342
let mut llargs = get_params(fcx.llfn);
343343
let fn_ret = callee.ty.fn_ret();
344344
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;
346346
let env_arg = &orig_fn_ty.args[0];
347347
let llenv = if env_arg.is_indirect() {
348-
llargs[idx]
348+
llargs[self_idx]
349349
} else {
350350
let scratch = alloc_ty(&bcx, closure_ty, "self");
351-
let mut llarg_idx = idx;
351+
let mut llarg_idx = self_idx;
352352
env_arg.store_fn_arg(&bcx, &mut llarg_idx, scratch);
353353
scratch
354354
};
@@ -357,22 +357,15 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
357357
// Adjust llargs such that llargs[self_idx..] has the call arguments.
358358
// For zero-sized closures that means sneaking in a new argument.
359359
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);
365361
} else {
366-
llargs[idx] = llenv;
362+
llargs[self_idx] = llenv;
367363
}
368364

369365
// Call the by-ref closure body with `self` in a cleanup scope,
370366
// to drop `self` when the body returns, or in case it unwinds.
371367
let self_scope = fcx.schedule_drop_mem(llenv, closure_ty);
372368

373-
if fn_ty.ret.is_indirect() {
374-
llargs.insert(0, get_param(fcx.llfn, 0));
375-
}
376369
let llfn = callee.reify(bcx.ccx);
377370
let llret;
378371
if let Some(landing_pad) = self_scope.landing_pad {

0 commit comments

Comments
 (0)