Removed the obsolete ast::CallSugar (previously used by do
).
This commit is contained in:
parent
07ea23e15d
commit
6e84023596
@ -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) |
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
@ -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));
|
||||
|
@ -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));
|
||||
@ -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));
|
||||
|
@ -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) => {
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -2624,7 +2624,7 @@ 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() {
|
||||
@ -2632,7 +2632,7 @@ fn populate_scope_map(cx: &CrateContext,
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
@ -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) {
|
||||
/*!
|
||||
@ -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);
|
||||
|
||||
@ -1783,24 +1774,8 @@ 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
|
||||
@ -1808,8 +1783,7 @@ pub fn check_expr_with_unifier(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);
|
||||
@ -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.
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
@ -1985,8 +1958,8 @@ 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();
|
||||
@ -1994,8 +1967,8 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
@ -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| {
|
||||
@ -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| {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 {}",
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ pub struct Expr {
|
||||
impl Expr {
|
||||
pub fn get_callee_id(&self) -> Option<NodeId> {
|
||||
match self.node {
|
||||
ExprMethodCall(callee_id, _, _, _, _) |
|
||||
ExprMethodCall(callee_id, _, _, _) |
|
||||
ExprIndex(callee_id, _, _) |
|
||||
ExprBinary(callee_id, _, _, _) |
|
||||
ExprAssignOp(callee_id, _, _, _) |
|
||||
@ -529,20 +529,14 @@ impl Expr {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub enum CallSugar {
|
||||
NoSugar,
|
||||
ForSugar
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub enum Expr_ {
|
||||
ExprVstore(@Expr, ExprVstore),
|
||||
// First expr is the place; second expr is the value.
|
||||
ExprBox(@Expr, @Expr),
|
||||
ExprVec(~[@Expr], Mutability),
|
||||
ExprCall(@Expr, ~[@Expr], CallSugar),
|
||||
ExprMethodCall(NodeId, Ident, ~[P<Ty>], ~[@Expr], CallSugar),
|
||||
ExprCall(@Expr, ~[@Expr]),
|
||||
ExprMethodCall(NodeId, Ident, ~[P<Ty>], ~[@Expr]),
|
||||
ExprTup(~[@Expr]),
|
||||
ExprBinary(NodeId, BinOp, @Expr, @Expr),
|
||||
ExprUnary(NodeId, UnOp, @Expr),
|
||||
|
@ -525,11 +525,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_call(&self, span: Span, expr: @ast::Expr, args: ~[@ast::Expr]) -> @ast::Expr {
|
||||
self.expr(span, ast::ExprCall(expr, args, ast::NoSugar))
|
||||
self.expr(span, ast::ExprCall(expr, args))
|
||||
}
|
||||
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr {
|
||||
self.expr(span,
|
||||
ast::ExprCall(self.expr_ident(span, id), args, ast::NoSugar))
|
||||
self.expr(span, ast::ExprCall(self.expr_ident(span, id), args))
|
||||
}
|
||||
fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident],
|
||||
args: ~[@ast::Expr]) -> @ast::Expr {
|
||||
@ -541,7 +540,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
ident: ast::Ident,
|
||||
mut args: ~[@ast::Expr]) -> @ast::Expr {
|
||||
args.unshift(expr);
|
||||
self.expr(span, ast::ExprMethodCall(ast::DUMMY_NODE_ID, ident, ~[], args, ast::NoSugar))
|
||||
self.expr(span, ast::ExprMethodCall(ast::DUMMY_NODE_ID, ident, ~[], args))
|
||||
}
|
||||
fn expr_block(&self, b: P<ast::Block>) -> @ast::Expr {
|
||||
self.expr(b.span, ast::ExprBlock(b))
|
||||
|
@ -727,19 +727,16 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
|
||||
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt)
|
||||
}
|
||||
ExprTup(ref elts) => ExprTup(elts.map(|x| folder.fold_expr(*x))),
|
||||
ExprCall(f, ref args, blk) => {
|
||||
ExprCall(f, ref args) => {
|
||||
ExprCall(folder.fold_expr(f),
|
||||
args.map(|&x| folder.fold_expr(x)),
|
||||
blk)
|
||||
args.map(|&x| folder.fold_expr(x)))
|
||||
}
|
||||
ExprMethodCall(callee_id, i, ref tps, ref args, blk) => {
|
||||
ExprMethodCall(callee_id, i, ref tps, ref args) => {
|
||||
ExprMethodCall(
|
||||
folder.new_id(callee_id),
|
||||
folder.fold_ident(i),
|
||||
tps.map(|&x| folder.fold_ty(x)),
|
||||
args.map(|&x| folder.fold_expr(x)),
|
||||
blk
|
||||
)
|
||||
args.map(|&x| folder.fold_expr(x)))
|
||||
}
|
||||
ExprBinary(callee_id, binop, lhs, rhs) => {
|
||||
ExprBinary(folder.new_id(callee_id),
|
||||
|
@ -23,15 +23,13 @@ use ast;
|
||||
// isn't parsed as (if true {...} else {...} | x) | 5
|
||||
pub fn expr_requires_semi_to_be_stmt(e: @ast::Expr) -> bool {
|
||||
match e.node {
|
||||
ast::ExprIf(..)
|
||||
| ast::ExprMatch(..)
|
||||
| ast::ExprBlock(_)
|
||||
| ast::ExprWhile(..)
|
||||
| ast::ExprLoop(..)
|
||||
| ast::ExprForLoop(..)
|
||||
| ast::ExprCall(_, _, ast::ForSugar)
|
||||
| ast::ExprMethodCall(_, _, _, _, ast::ForSugar) => false,
|
||||
_ => true
|
||||
ast::ExprIf(..)
|
||||
| ast::ExprMatch(..)
|
||||
| ast::ExprBlock(_)
|
||||
| ast::ExprWhile(..)
|
||||
| ast::ExprLoop(..)
|
||||
| ast::ExprForLoop(..) => false,
|
||||
_ => true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
use abi;
|
||||
use abi::AbiSet;
|
||||
use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil};
|
||||
use ast::{CallSugar, NoSugar};
|
||||
use ast::{BareFnTy, ClosureTy};
|
||||
use ast::{RegionTyParamBound, TraitTyParamBound};
|
||||
use ast::{Provided, Public, Purity};
|
||||
@ -1690,13 +1689,12 @@ impl Parser {
|
||||
ExprBinary(ast::DUMMY_NODE_ID, binop, lhs, rhs)
|
||||
}
|
||||
|
||||
pub fn mk_call(&mut self, f: @Expr, args: ~[@Expr], sugar: CallSugar) -> ast::Expr_ {
|
||||
ExprCall(f, args, sugar)
|
||||
pub fn mk_call(&mut self, f: @Expr, args: ~[@Expr]) -> ast::Expr_ {
|
||||
ExprCall(f, args)
|
||||
}
|
||||
|
||||
fn mk_method_call(&mut self, ident: Ident, tps: ~[P<Ty>], args: ~[@Expr],
|
||||
sugar: CallSugar) -> ast::Expr_ {
|
||||
ExprMethodCall(ast::DUMMY_NODE_ID, ident, tps, args, sugar)
|
||||
fn mk_method_call(&mut self, ident: Ident, tps: ~[P<Ty>], args: ~[@Expr]) -> ast::Expr_ {
|
||||
ExprMethodCall(ast::DUMMY_NODE_ID, ident, tps, args)
|
||||
}
|
||||
|
||||
pub fn mk_index(&mut self, expr: @Expr, idx: @Expr) -> ast::Expr_ {
|
||||
@ -1997,7 +1995,7 @@ impl Parser {
|
||||
hi = self.last_span.hi;
|
||||
|
||||
es.unshift(e);
|
||||
let nd = self.mk_method_call(i, tys, es, NoSugar);
|
||||
let nd = self.mk_method_call(i, tys, es);
|
||||
e = self.mk_expr(lo, hi, nd);
|
||||
}
|
||||
_ => {
|
||||
@ -2022,7 +2020,7 @@ impl Parser {
|
||||
);
|
||||
hi = self.last_span.hi;
|
||||
|
||||
let nd = self.mk_call(e, es, NoSugar);
|
||||
let nd = self.mk_call(e, es);
|
||||
e = self.mk_expr(lo, hi, nd);
|
||||
}
|
||||
|
||||
|
@ -1141,33 +1141,10 @@ pub fn print_expr_vstore(s: &mut State, t: ast::ExprVstore) -> io::IoResult<()>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_call_pre(s: &mut State,
|
||||
sugar: ast::CallSugar,
|
||||
base_args: &mut ~[@ast::Expr])
|
||||
-> io::IoResult<Option<@ast::Expr>> {
|
||||
match sugar {
|
||||
ast::ForSugar => {
|
||||
if_ok!(head(s, "for"));
|
||||
Ok(Some(base_args.pop().unwrap()))
|
||||
}
|
||||
ast::NoSugar => Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_call_post(s: &mut State,
|
||||
sugar: ast::CallSugar,
|
||||
blk: &Option<@ast::Expr>,
|
||||
base_args: &mut ~[@ast::Expr]) -> io::IoResult<()> {
|
||||
if sugar == ast::NoSugar || !base_args.is_empty() {
|
||||
if_ok!(popen(s));
|
||||
if_ok!(commasep_exprs(s, Inconsistent, *base_args));
|
||||
if_ok!(pclose(s));
|
||||
}
|
||||
if sugar != ast::NoSugar {
|
||||
if_ok!(nbsp(s));
|
||||
// not sure if this can happen
|
||||
if_ok!(print_expr(s, blk.unwrap()));
|
||||
}
|
||||
fn print_call_post(s: &mut State, args: &[@ast::Expr]) -> io::IoResult<()> {
|
||||
if_ok!(popen(s));
|
||||
if_ok!(commasep_exprs(s, Inconsistent, args));
|
||||
if_ok!(pclose(s));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1254,15 +1231,12 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
|
||||
}
|
||||
if_ok!(pclose(s));
|
||||
}
|
||||
ast::ExprCall(func, ref args, sugar) => {
|
||||
let mut base_args = (*args).clone();
|
||||
let blk = if_ok!(print_call_pre(s, sugar, &mut base_args));
|
||||
ast::ExprCall(func, ref args) => {
|
||||
if_ok!(print_expr(s, func));
|
||||
if_ok!(print_call_post(s, sugar, &blk, &mut base_args));
|
||||
if_ok!(print_call_post(s, *args));
|
||||
}
|
||||
ast::ExprMethodCall(_, ident, ref tys, ref args, sugar) => {
|
||||
let mut base_args = args.slice_from(1).to_owned();
|
||||
let blk = if_ok!(print_call_pre(s, sugar, &mut base_args));
|
||||
ast::ExprMethodCall(_, ident, ref tys, ref args) => {
|
||||
let base_args = args.slice_from(1);
|
||||
if_ok!(print_expr(s, args[0]));
|
||||
if_ok!(word(&mut s.s, "."));
|
||||
if_ok!(print_ident(s, ident));
|
||||
@ -1271,7 +1245,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
|
||||
if_ok!(commasep(s, Inconsistent, *tys, print_type_ref));
|
||||
if_ok!(word(&mut s.s, ">"));
|
||||
}
|
||||
if_ok!(print_call_post(s, sugar, &blk, &mut base_args));
|
||||
if_ok!(print_call_post(s, base_args));
|
||||
}
|
||||
ast::ExprBinary(_, op, lhs, rhs) => {
|
||||
if_ok!(print_expr(s, lhs));
|
||||
|
@ -652,13 +652,13 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en
|
||||
visitor.visit_expr(*subexpression, env.clone())
|
||||
}
|
||||
}
|
||||
ExprCall(callee_expression, ref arguments, _) => {
|
||||
ExprCall(callee_expression, ref arguments) => {
|
||||
for argument in arguments.iter() {
|
||||
visitor.visit_expr(*argument, env.clone())
|
||||
}
|
||||
visitor.visit_expr(callee_expression, env.clone())
|
||||
}
|
||||
ExprMethodCall(_, _, ref types, ref arguments, _) => {
|
||||
ExprMethodCall(_, _, ref types, ref arguments) => {
|
||||
walk_exprs(visitor, *arguments, env.clone());
|
||||
for &typ in types.iter() {
|
||||
visitor.visit_ty(typ, env.clone())
|
||||
|
Loading…
x
Reference in New Issue
Block a user