_ => panic!("expected bare rust fn or closure in trans_call_inner")
};
- let (llfn, llenv, llself) = match callee.data {
+ let (llfn, llself) = match callee.data {
Fn(llfn) => {
- (llfn, None, None)
+ (llfn, None)
}
TraitItem(d) => {
- (d.llfn, None, Some(d.llself))
+ (d.llfn, Some(d.llself))
}
Intrinsic(node, substs) => {
assert!(abi == synabi::RustIntrinsic);
}
}
- // Push the environment (or a trait object's self).
- match (llenv, llself) {
- (Some(llenv), None) => llargs.push(llenv),
- (None, Some(llself)) => llargs.push(llself),
- _ => {}
+ // Push a trait object's self.
+ if let Some(llself) = llself {
+ llargs.push(llself);
}
// Push the arguments.
// value.
ArgVals(&'a [ValueRef]),
- // For overloaded operators: `(lhs, Vec(rhs, rhs_id), autoref)`. `lhs`
+ // For overloaded operators: `(lhs, Option(rhs, rhs_id), autoref)`. `lhs`
// is the left-hand-side and `rhs/rhs_id` is the datum/expr-id of
- // the right-hand-side arguments (if any). `autoref` indicates whether the `rhs`
+ // the right-hand-side argument (if any). `autoref` indicates whether the `rhs`
// arguments should be auto-referenced
- ArgOverloadedOp(Datum<'tcx, Expr>, Vec<(Datum<'tcx, Expr>, ast::NodeId)>, bool),
+ ArgOverloadedOp(Datum<'tcx, Expr>, Option<(Datum<'tcx, Expr>, ast::NodeId)>, bool),
// Supply value of arguments as a list of expressions that must be
// translated, for overloaded call operators.
DontAutorefArg,
llargs);
- assert_eq!(arg_tys.len(), 1 + rhs.len());
- for (rhs, rhs_id) in rhs {
+ if let Some((rhs, rhs_id)) = rhs {
+ assert_eq!(arg_tys.len(), 2);
bcx = trans_arg_datum(bcx, arg_tys[1], rhs,
arg_cleanup_scope,
if autoref { DoAutorefArg(rhs_id) } else { DontAutorefArg },
llargs);
+ } else {
+ assert_eq!(arg_tys.len(), 1);
}
}
ArgVals(vs) => {
index_expr,
method_call,
base_datum,
- vec![(ix_datum, idx.id)],
+ Some((ix_datum, idx.id)),
Some(SaveIn(scratch.val)),
false));
let datum = scratch.to_expr_datum();
let lhs = unpack_datum!(bcx, trans(bcx, &**lhs));
let rhs_datum = unpack_datum!(bcx, trans(bcx, &**rhs));
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), lhs,
- vec![(rhs_datum, rhs.id)], Some(dest),
+ Some((rhs_datum, rhs.id)), Some(dest),
!ast_util::is_by_value_binop(op.node)).bcx
}
ast::ExprUnary(op, ref subexpr) => {
// if not overloaded, would be RvalueDatumExpr
let arg = unpack_datum!(bcx, trans(bcx, &**subexpr));
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id),
- arg, Vec::new(), Some(dest), !ast_util::is_by_value_unop(op)).bcx
+ arg, None, Some(dest), !ast_util::is_by_value_unop(op)).bcx
}
ast::ExprIndex(ref base, ref idx) => {
// if not overloaded, would be RvalueDatumExpr
let base = unpack_datum!(bcx, trans(bcx, &**base));
let idx_datum = unpack_datum!(bcx, trans(bcx, &**idx));
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), base,
- vec![(idx_datum, idx.id)], Some(dest), true).bcx
+ Some((idx_datum, idx.id)), Some(dest), true).bcx
}
ast::ExprCast(..) => {
// Trait casts used to come this way, now they should be coercions.
expr: &ast::Expr,
method_call: MethodCall,
lhs: Datum<'tcx, Expr>,
- rhs: Vec<(Datum<'tcx, Expr>, ast::NodeId)>,
+ rhs: Option<(Datum<'tcx, Expr>, ast::NodeId)>,
dest: Option<Dest>,
autoref: bool)
-> Result<'blk, 'tcx> {
let scratch = rvalue_scratch_datum(bcx, ref_ty, "overloaded_deref");
unpack_result!(bcx, trans_overloaded_op(bcx, expr, method_call,
- datum, Vec::new(), Some(SaveIn(scratch.val)),
+ datum, None, Some(SaveIn(scratch.val)),
false));
scratch.to_expr_datum()
}