diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-23 10:56:10 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-23 11:02:27 +0100 |
| commit | 9fb3719ded8d6938c21710d4b487ab1328c7dd5e (patch) | |
| tree | 6612e313512e59a050093108962e371616d0eab9 /src/comp/syntax/parse | |
| parent | acbc4aa9f8f46545c8c11422c62b392e3ef64cf5 (diff) | |
| download | rust-9fb3719ded8d6938c21710d4b487ab1328c7dd5e.tar.gz rust-9fb3719ded8d6938c21710d4b487ab1328c7dd5e.zip | |
Rollback return-by-reference
It's proving too inflexible, so I'm ripping out the extra complexity in the hope that regions will, at some point, provide something similar. Closes #918
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 35c1e1190d3..391d5eb8819 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -295,7 +295,7 @@ fn parse_ty_fn(proto: ast::proto, p: parser) -> ast::ty_ { // FIXME: there's no syntax for this right now anyway // auto constrs = parse_constrs(~[], p); let constrs: [@ast::constr] = []; - let (ret_style, ret_ty) = parse_ret_ty(p, vec::len(inputs.node)); + let (ret_style, ret_ty) = parse_ret_ty(p); ret ast::ty_fn(proto, inputs.node, ret_ty, ret_style, constrs); } @@ -439,34 +439,12 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool) } } -fn parse_ret_ty(p: parser, n_args: uint) -> (ast::ret_style, @ast::ty) { +fn parse_ret_ty(p: parser) -> (ast::ret_style, @ast::ty) { ret if eat(p, token::RARROW) { let lo = p.get_lo_pos(); if eat(p, token::NOT) { (ast::noreturn, @spanned(lo, p.get_last_hi_pos(), ast::ty_bot)) - } else { - let style = ast::return_val; - if eat(p, token::BINOP(token::AND)) { - if n_args == 0u { - p.fatal("can not return reference from argument-less fn"); - } - let mut_root = eat(p, token::NOT), arg = 1u; - alt p.peek() { - token::LIT_INT(val) { p.bump(); arg = val as uint; } - _ { if n_args > 1u { - p.fatal("must specify referenced parameter"); - } } - } - if arg > n_args { - p.fatal("referenced argument does not exist"); - } - if arg == 0u { - p.fatal("referenced argument can't be 0"); - } - style = ast::return_ref(mut_root, arg); - }; - (style, parse_ty(p, false)) - } + } else { (ast::return_val, parse_ty(p, false)) } } else { let pos = p.get_lo_pos(); (ast::return_val, @spanned(pos, pos, ast::ty_nil)) @@ -1791,7 +1769,7 @@ fn parse_fn_decl(p: parser, purity: ast::purity, il: ast::inlineness) -> p.bump(); constrs = parse_constrs({|x| parse_ty_constr(inputs.node, x) }, p); } - let (ret_style, ret_ty) = parse_ret_ty(p, vec::len(inputs.node)); + let (ret_style, ret_ty) = parse_ret_ty(p); ret {inputs: inputs.node, output: ret_ty, purity: purity, |
