Skip to content

Removed the obsolete ast::CallSugar (previously used by do). #12259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,10 @@ fn check_loans_in_expr<'a>(this: &mut CheckLoanCtxt<'a>,
ast::ExprAssignOp(_, _, dest, _) => {
this.check_assignment(dest);
}
ast::ExprCall(f, ref args, _) => {
ast::ExprCall(f, ref args) => {
this.check_call(expr, Some(f), f.id, f.span, *args);
}
ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
ast::ExprMethodCall(callee_id, _, _, ref args) => {
this.check_call(expr, None, callee_id, expr.span, *args);
}
ast::ExprIndex(callee_id, _, rval) |
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ impl CFGBuilder {
self.straightline(expr, pred, *elems)
}

ast::ExprCall(func, ref args, _) => {
ast::ExprCall(func, ref args) => {
self.call(expr, pred, func, *args)
}

ast::ExprMethodCall(_, _, _, ref args, _) => {
ast::ExprMethodCall(_, _, _, ref args) => {
self.call(expr, pred, args[0], args.slice_from(1))
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
}
}
}
ExprCall(callee, _, NoSugar) => {
ExprCall(callee, _) => {
let def_map = def_map.borrow();
match def_map.get().find(&callee.id) {
Some(&DefStruct(..)) => {} // OK.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,12 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
self.walk_opt_expr(with_expr, in_out, loop_scopes);
}

ast::ExprCall(f, ref args, _) => {
ast::ExprCall(f, ref args) => {
self.walk_expr(f, in_out, loop_scopes);
self.walk_call(f.id, expr.id, *args, in_out, loop_scopes);
}

ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
ast::ExprMethodCall(callee_id, _, _, ref args) => {
self.walk_call(callee_id, expr.id, *args, in_out, loop_scopes);
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Visitor<()> for EffectCheckVisitor {

fn visit_expr(&mut self, expr: &ast::Expr, _:()) {
match expr.node {
ast::ExprMethodCall(callee_id, _, _, _, _) => {
ast::ExprMethodCall(callee_id, _, _, _) => {
let base_type = ty::node_id_to_type(self.tcx, callee_id);
debug!("effect: method call case, base type is {}",
ppaux::ty_to_str(self.tcx, base_type));
Expand All @@ -129,7 +129,7 @@ impl Visitor<()> for EffectCheckVisitor {
"invocation of unsafe method")
}
}
ast::ExprCall(base, _, _) => {
ast::ExprCall(base, _) => {
let base_type = ty::node_id_to_type(self.tcx, base.id);
debug!("effect: call case, base type is {}",
ppaux::ty_to_str(self.tcx, base_type));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ impl Liveness {
})
}

ExprCall(f, ref args, _) => {
ExprCall(f, ref args) => {
// calling a fn with bot return type means that the fn
// will fail, and hence the successors can be ignored
let t_ret = ty::ty_fn_ret(ty::expr_ty(self.tcx, f));
Expand All @@ -1215,7 +1215,7 @@ impl Liveness {
self.propagate_through_expr(f, succ)
}

ExprMethodCall(callee_id, _, _, ref args, _) => {
ExprMethodCall(callee_id, _, _, ref args) => {
// calling a method with bot return type means that the method
// will fail, and hence the successors can be ignored
let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx, callee_id));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl VisitContext {
}
}

ExprCall(callee, ref args, _) => { // callee(args)
ExprCall(callee, ref args) => { // callee(args)
// Figure out whether the called function is consumed.
let mode = match ty::get(ty::expr_ty(self.tcx, callee)).sty {
ty::ty_closure(ref cty) => {
Expand Down Expand Up @@ -412,7 +412,7 @@ impl VisitContext {
self.use_fn_args(callee.id, *args);
}

ExprMethodCall(callee_id, _, _, ref args, _) => { // callee.m(args)
ExprMethodCall(callee_id, _, _, ref args) => { // callee.m(args)
self.use_fn_args(callee_id, *args);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
_ => {}
}
}
ast::ExprMethodCall(_, ident, _, ref args, _) => {
ast::ExprMethodCall(_, ident, _, ref args) => {
// see above
let t = ty::type_autoderef(ty::expr_ty(self.tcx, args[0]));
match ty::get(t).sty {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5221,7 +5221,7 @@ impl Resolver {
let traits = self.search_for_traits_containing_method(ident);
self.trait_map.insert(expr.id, @RefCell::new(traits));
}
ExprMethodCall(_, ident, _, _, _) => {
ExprMethodCall(_, ident, _, _) => {
debug!("(recording candidate traits for expr) recording \
traits for {}",
expr.id);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
}
}
}
ast::ExprCall(callee, ref args, _) => {
ast::ExprCall(callee, ref args) => {
let tcx = cx.tcx;
let opt_def = {
let def_map = tcx.def_map.borrow();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2624,15 +2624,15 @@ fn populate_scope_map(cx: &CrateContext,
})
}

ast::ExprCall(fn_exp, ref args, _) => {
ast::ExprCall(fn_exp, ref args) => {
walk_expr(cx, fn_exp, scope_stack, scope_map);

for arg_exp in args.iter() {
walk_expr(cx, *arg_exp, scope_stack, scope_map);
}
}

ast::ExprMethodCall(node_id, _, _, ref args, _) => {
ast::ExprMethodCall(node_id, _, _, ref args) => {
scope_map.insert(node_id, scope_stack.last().unwrap().scope_metadata);

for arg_exp in args.iter() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,11 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
expr_to_str(expr), expr_ty.repr(tcx));
closure::trans_expr_fn(bcx, sigil, decl, body, expr.id, dest)
}
ast::ExprCall(f, ref args, _) => {
ast::ExprCall(f, ref args) => {
callee::trans_call(bcx, expr, f,
callee::ArgExprs(*args), expr.id, dest)
}
ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
ast::ExprMethodCall(callee_id, _, _, ref args) => {
callee::trans_method_call(bcx, expr, callee_id, args[0],
callee::ArgExprs(*args), dest)
}
Expand Down
69 changes: 21 additions & 48 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,22 +1592,20 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
method_fn_ty: ty::t,
callee_expr: &ast::Expr,
args: &[@ast::Expr],
sugar: ast::CallSugar,
deref_args: DerefArgs) -> ty::t
{
deref_args: DerefArgs) -> ty::t {
// HACK(eddyb) ignore provided self (it has special typeck rules).
let args = args.slice_from(1);
if ty::type_is_error(method_fn_ty) {
let err_inputs = err_args(args.len());
check_argument_types(fcx, sp, err_inputs, callee_expr,
args, sugar, deref_args, false);
args, deref_args, false);
method_fn_ty
} else {
match ty::get(method_fn_ty).sty {
ty::ty_bare_fn(ref fty) => {
// HACK(eddyb) ignore self in the definition (see above).
check_argument_types(fcx, sp, fty.sig.inputs.slice_from(1),
callee_expr, args, sugar, deref_args,
callee_expr, args, deref_args,
fty.sig.variadic);
fty.sig.output
}
Expand All @@ -1625,7 +1623,6 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
fn_inputs: &[ty::t],
callee_expr: &ast::Expr,
args: &[@ast::Expr],
sugar: ast::CallSugar,
deref_args: DerefArgs,
variadic: bool) {
/*!
Expand Down Expand Up @@ -1659,18 +1656,12 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
err_args(supplied_arg_count)
}
} else {
let suffix = match sugar {
ast::NoSugar => "",
ast::ForSugar => " (including the closure passed by \
the `for` keyword)"
};
let msg = format!(
"this function takes {} parameter{} \
but {} parameter{} supplied{}",
but {} parameter{} supplied",
expected_arg_count, if expected_arg_count == 1 {""} else {"s"},
supplied_arg_count,
if supplied_arg_count == 1 {" was"} else {"s were"},
suffix);
if supplied_arg_count == 1 {" was"} else {"s were"});

tcx.sess.span_err(sp, msg);

Expand Down Expand Up @@ -1783,33 +1774,16 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
// The callee checks for bot / err, we don't need to
}

fn write_call(fcx: @FnCtxt,
call_expr: &ast::Expr,
output: ty::t,
sugar: ast::CallSugar) {
let ret_ty = match sugar {
ast::ForSugar => {
match ty::get(output).sty {
ty::ty_bool => {}
_ => fcx.type_error_message(call_expr.span, |actual| {
format!("expected `for` closure to return `bool`, \
but found `{}`", actual) },
output, None)
}
ty::mk_nil()
}
_ => output
};
fcx.write_ty(call_expr.id, ret_ty);
fn write_call(fcx: @FnCtxt, call_expr: &ast::Expr, output: ty::t) {
fcx.write_ty(call_expr.id, output);
}

// A generic function for doing all of the checking for call expressions
fn check_call(fcx: @FnCtxt,
callee_id: ast::NodeId,
call_expr: &ast::Expr,
f: &ast::Expr,
args: &[@ast::Expr],
sugar: ast::CallSugar) {
args: &[@ast::Expr]) {
// Index expressions need to be handled separately, to inform them
// that they appear in call position.
check_expr(fcx, f);
Expand Down Expand Up @@ -1857,9 +1831,9 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,

// Call the generic checker.
check_argument_types(fcx, call_expr.span, fn_sig.inputs, f,
args, sugar, DontDerefArgs, fn_sig.variadic);
args, DontDerefArgs, fn_sig.variadic);

write_call(fcx, call_expr, fn_sig.output, sugar);
write_call(fcx, call_expr, fn_sig.output);
}

// Checks a method call.
Expand All @@ -1868,8 +1842,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
expr: &ast::Expr,
method_name: ast::Ident,
args: &[@ast::Expr],
tps: &[ast::P<ast::Ty>],
sugar: ast::CallSugar) {
tps: &[ast::P<ast::Ty>]) {
let rcvr = args[0];
check_expr(fcx, rcvr);

Expand Down Expand Up @@ -1915,10 +1888,10 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
// Call the generic checker.
let fn_ty = fcx.node_ty(callee_id);
let ret_ty = check_method_argument_types(fcx, expr.span,
fn_ty, expr, args, sugar,
fn_ty, expr, args,
DontDerefArgs);

write_call(fcx, expr, ret_ty, sugar);
write_call(fcx, expr, ret_ty);
}

// A generic function for checking the then and else in an if
Expand Down Expand Up @@ -1985,17 +1958,17 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
method_map.get().insert(op_ex.id, *origin);
}
check_method_argument_types(fcx, op_ex.span,
method_ty, op_ex, args,
ast::NoSugar, deref_args)
method_ty, op_ex,
args, deref_args)
}
_ => {
unbound_method();
// Check the args anyway
// so we get all the error messages
let expected_ty = ty::mk_err();
check_method_argument_types(fcx, op_ex.span,
expected_ty, op_ex, args,
ast::NoSugar, deref_args);
expected_ty, op_ex,
args, deref_args);
ty::mk_err()
}
}
Expand Down Expand Up @@ -2948,8 +2921,8 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
check_block_with_expected(fcx, b, expected);
fcx.write_ty(id, fcx.node_ty(b.id));
}
ast::ExprCall(f, ref args, sugar) => {
check_call(fcx, expr.id, expr, f, *args, sugar);
ast::ExprCall(f, ref args) => {
check_call(fcx, expr.id, expr, f, *args);
let f_ty = fcx.expr_ty(f);
let (args_bot, args_err) = args.iter().fold((false, false),
|(rest_bot, rest_err), a| {
Expand All @@ -2964,8 +2937,8 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
fcx.write_bot(id);
}
}
ast::ExprMethodCall(callee_id, ident, ref tps, ref args, sugar) => {
check_method_call(fcx, callee_id, expr, ident, *args, *tps, sugar);
ast::ExprMethodCall(callee_id, ident, ref tps, ref args) => {
check_method_call(fcx, callee_id, expr, ident, *args, *tps);
let arg_tys = args.map(|a| fcx.expr_ty(*a));
let (args_bot, args_err) = arg_tys.iter().fold((false, false),
|(rest_bot, rest_err), a| {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,14 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
}

match expr.node {
ast::ExprCall(callee, ref args, _) => {
ast::ExprCall(callee, ref args) => {
constrain_callee(rcx, callee.id, expr, callee);
constrain_call(rcx, callee.id, expr, None, *args, false);

visit::walk_expr(rcx, expr, ());
}

ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
ast::ExprMethodCall(callee_id, _, _, ref args) => {
constrain_call(rcx, callee_id, expr, Some(args[0]),
args.slice_from(1), false);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: @FnCtxt, is_early: bool) {
ast::ExprUnary(callee_id, _, _) |
ast::ExprAssignOp(callee_id, _, _, _) |
ast::ExprIndex(callee_id, _, _) |
ast::ExprMethodCall(callee_id, _, _, _, _) => {
ast::ExprMethodCall(callee_id, _, _, _) => {
match ty::method_call_type_param_defs(cx.tcx, fcx.inh.method_map, ex.id) {
Some(type_param_defs) => {
debug!("vtable resolution on parameter bounds for method call {}",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn visit_expr(e: &ast::Expr, wbcx: &mut WbCtxt) {
maybe_resolve_type_vars_for_node(wbcx, e.span, callee_id);
}

ast::ExprMethodCall(callee_id, _, _, _, _) => {
ast::ExprMethodCall(callee_id, _, _, _) => {
// We must always have written in a callee ID type for these.
resolve_type_vars_for_node(wbcx, e.span, callee_id);
}
Expand Down
Loading