Skip to content

Commit a5447e1

Browse files
committed
rustc_trans: remove some outdated and unused logic from callee.
1 parent 5620a58 commit a5447e1

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/librustc_trans/trans/callee.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,12 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
698698
_ => panic!("expected bare rust fn or closure in trans_call_inner")
699699
};
700700

701-
let (llfn, llenv, llself) = match callee.data {
701+
let (llfn, llself) = match callee.data {
702702
Fn(llfn) => {
703-
(llfn, None, None)
703+
(llfn, None)
704704
}
705705
TraitItem(d) => {
706-
(d.llfn, None, Some(d.llself))
706+
(d.llfn, Some(d.llself))
707707
}
708708
Intrinsic(node, substs) => {
709709
assert!(abi == synabi::RustIntrinsic);
@@ -794,11 +794,9 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
794794
}
795795
}
796796

797-
// Push the environment (or a trait object's self).
798-
match (llenv, llself) {
799-
(Some(llenv), None) => llargs.push(llenv),
800-
(None, Some(llself)) => llargs.push(llself),
801-
_ => {}
797+
// Push a trait object's self.
798+
if let Some(llself) = llself {
799+
llargs.push(llself);
802800
}
803801

804802
// Push the arguments.
@@ -894,11 +892,11 @@ pub enum CallArgs<'a, 'tcx> {
894892
// value.
895893
ArgVals(&'a [ValueRef]),
896894

897-
// For overloaded operators: `(lhs, Vec(rhs, rhs_id), autoref)`. `lhs`
895+
// For overloaded operators: `(lhs, Option(rhs, rhs_id), autoref)`. `lhs`
898896
// is the left-hand-side and `rhs/rhs_id` is the datum/expr-id of
899-
// the right-hand-side arguments (if any). `autoref` indicates whether the `rhs`
897+
// the right-hand-side argument (if any). `autoref` indicates whether the `rhs`
900898
// arguments should be auto-referenced
901-
ArgOverloadedOp(Datum<'tcx, Expr>, Vec<(Datum<'tcx, Expr>, ast::NodeId)>, bool),
899+
ArgOverloadedOp(Datum<'tcx, Expr>, Option<(Datum<'tcx, Expr>, ast::NodeId)>, bool),
902900

903901
// Supply value of arguments as a list of expressions that must be
904902
// translated, for overloaded call operators.
@@ -1077,12 +1075,14 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
10771075
DontAutorefArg,
10781076
llargs);
10791077

1080-
assert_eq!(arg_tys.len(), 1 + rhs.len());
1081-
for (rhs, rhs_id) in rhs {
1078+
if let Some((rhs, rhs_id)) = rhs {
1079+
assert_eq!(arg_tys.len(), 2);
10821080
bcx = trans_arg_datum(bcx, arg_tys[1], rhs,
10831081
arg_cleanup_scope,
10841082
if autoref { DoAutorefArg(rhs_id) } else { DontAutorefArg },
10851083
llargs);
1084+
} else {
1085+
assert_eq!(arg_tys.len(), 1);
10861086
}
10871087
}
10881088
ArgVals(vs) => {

src/librustc_trans/trans/expr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
805805
index_expr,
806806
method_call,
807807
base_datum,
808-
vec![(ix_datum, idx.id)],
808+
Some((ix_datum, idx.id)),
809809
Some(SaveIn(scratch.val)),
810810
false));
811811
let datum = scratch.to_expr_datum();
@@ -1175,21 +1175,21 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11751175
let lhs = unpack_datum!(bcx, trans(bcx, &**lhs));
11761176
let rhs_datum = unpack_datum!(bcx, trans(bcx, &**rhs));
11771177
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), lhs,
1178-
vec![(rhs_datum, rhs.id)], Some(dest),
1178+
Some((rhs_datum, rhs.id)), Some(dest),
11791179
!ast_util::is_by_value_binop(op.node)).bcx
11801180
}
11811181
ast::ExprUnary(op, ref subexpr) => {
11821182
// if not overloaded, would be RvalueDatumExpr
11831183
let arg = unpack_datum!(bcx, trans(bcx, &**subexpr));
11841184
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id),
1185-
arg, Vec::new(), Some(dest), !ast_util::is_by_value_unop(op)).bcx
1185+
arg, None, Some(dest), !ast_util::is_by_value_unop(op)).bcx
11861186
}
11871187
ast::ExprIndex(ref base, ref idx) => {
11881188
// if not overloaded, would be RvalueDatumExpr
11891189
let base = unpack_datum!(bcx, trans(bcx, &**base));
11901190
let idx_datum = unpack_datum!(bcx, trans(bcx, &**idx));
11911191
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), base,
1192-
vec![(idx_datum, idx.id)], Some(dest), true).bcx
1192+
Some((idx_datum, idx.id)), Some(dest), true).bcx
11931193
}
11941194
ast::ExprCast(..) => {
11951195
// Trait casts used to come this way, now they should be coercions.
@@ -1943,7 +1943,7 @@ fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
19431943
expr: &ast::Expr,
19441944
method_call: MethodCall,
19451945
lhs: Datum<'tcx, Expr>,
1946-
rhs: Vec<(Datum<'tcx, Expr>, ast::NodeId)>,
1946+
rhs: Option<(Datum<'tcx, Expr>, ast::NodeId)>,
19471947
dest: Option<Dest>,
19481948
autoref: bool)
19491949
-> Result<'blk, 'tcx> {
@@ -2259,7 +2259,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
22592259
let scratch = rvalue_scratch_datum(bcx, ref_ty, "overloaded_deref");
22602260

22612261
unpack_result!(bcx, trans_overloaded_op(bcx, expr, method_call,
2262-
datum, Vec::new(), Some(SaveIn(scratch.val)),
2262+
datum, None, Some(SaveIn(scratch.val)),
22632263
false));
22642264
scratch.to_expr_datum()
22652265
}

0 commit comments

Comments
 (0)