diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-01-30 21:00:57 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-01-31 10:08:24 -0800 |
| commit | fba35e1a3c87892823d1f4d436b9f00a7864cf16 (patch) | |
| tree | 1fadaaee99ef266bd2f709fb2aa5577184ab611e /src/comp/syntax/parse | |
| parent | 813a55d89135efb716dd80e96453a091a7cfc631 (diff) | |
| download | rust-fba35e1a3c87892823d1f4d436b9f00a7864cf16.tar.gz rust-fba35e1a3c87892823d1f4d436b9f00a7864cf16.zip | |
Require alts to be exhaustive
middle::check_alt does the work. Lots of changes to add default cases into alts that were previously inexhaustive.
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 1c81eda7df5..95c37b9b8e9 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -258,7 +258,7 @@ fn check_bad_word(p: parser) { } } -fn parse_ty_fn(proto: ast::proto, p: parser) -> ast::ty_ { +fn parse_ty_fn(p: parser) -> ast::fn_decl { fn parse_fn_input_ty(p: parser) -> ast::arg { let mode = parse_arg_mode(p); let name = if is_plain_ident(p) && p.look_ahead(1u) == token::COLON { @@ -275,9 +275,9 @@ fn parse_ty_fn(proto: ast::proto, p: parser) -> ast::ty_ { // auto constrs = parse_constrs(~[], p); let constrs: [@ast::constr] = []; let (ret_style, ret_ty) = parse_ret_ty(p); - ret ast::ty_fn(proto, {inputs: inputs.node, output: ret_ty, + ret {inputs: inputs.node, output: ret_ty, purity: ast::impure_fn, cf: ret_style, - constraints: constrs}); + constraints: constrs}; } fn parse_ty_methods(p: parser) -> [ast::ty_method] { @@ -287,15 +287,10 @@ fn parse_ty_methods(p: parser) -> [ast::ty_method] { expect_word(p, "fn"); let ident = parse_method_name(p); let tps = parse_ty_params(p); - let f = parse_ty_fn(ast::proto_bare, p), fhi = p.last_span.hi; + let d = parse_ty_fn(p), fhi = p.last_span.hi; expect(p, token::SEMI); - alt f { - ast::ty_fn(_, d) { {ident: ident, attrs: attrs, decl: d, tps: tps, - span: ast_util::mk_sp(flo, fhi)} - } - } - }, p).node + span: ast_util::mk_sp(flo, fhi)}}, p).node } fn parse_mt(p: parser) -> ast::mt { @@ -506,10 +501,10 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty { ast::proto_bare { p.warn("fn is deprecated, use native fn"); } _ { /* fallthrough */ } } - t = parse_ty_fn(proto, p); + t = ast::ty_fn(proto, parse_ty_fn(p)); } else if eat_word(p, "native") { expect_word(p, "fn"); - t = parse_ty_fn(ast::proto_bare, p); + t = ast::ty_fn(ast::proto_bare, parse_ty_fn(p)); } else if p.token == token::MOD_SEP || is_ident(p.token) { let path = parse_path(p); t = ast::ty_path(path, p.get_id()); |
