From 77b06d24cd76bf808138f1f7df4dcff40260ff38 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 2 Feb 2012 16:50:17 -0800 Subject: infer modes rather than overwriting with expected ty --- src/comp/syntax/parse/parser.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/comp/syntax/parse') diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index a4ed54f2675..0b321b17b92 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -521,14 +521,19 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty { } fn parse_arg_mode(p: parser) -> ast::mode { - if eat(p, token::BINOP(token::AND)) { ast::by_mut_ref } - else if eat(p, token::BINOP(token::MINUS)) { ast::by_move } - else if eat(p, token::ANDAND) { ast::by_ref } - else if eat(p, token::BINOP(token::PLUS)) { - if eat(p, token::BINOP(token::PLUS)) { ast::by_val } - else { ast::by_copy } - } - else { ast::mode_infer } + if eat(p, token::BINOP(token::AND)) { + ast::expl(ast::by_mut_ref) + } else if eat(p, token::BINOP(token::MINUS)) { + ast::expl(ast::by_move) + } else if eat(p, token::ANDAND) { + ast::expl(ast::by_ref) + } else if eat(p, token::BINOP(token::PLUS)) { + if eat(p, token::BINOP(token::PLUS)) { + ast::expl(ast::by_val) + } else { + ast::expl(ast::by_copy) + } + } else { ast::infer(p.get_id()) } } fn parse_arg(p: parser) -> ast::arg { @@ -1984,8 +1989,8 @@ fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item { let dtor = parse_block_no_value(p); let decl = {inputs: - [{mode: ast::by_ref, ty: t, ident: arg_ident, - id: p.get_id()}], + [{mode: ast::expl(ast::by_ref), ty: t, + ident: arg_ident, id: p.get_id()}], output: @spanned(lo, lo, ast::ty_nil), purity: ast::impure_fn, cf: ast::return_val, -- cgit 1.4.1-3-g733a5