diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-02-12 15:01:29 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-02-16 08:03:58 -0500 |
| commit | 6c728e32c0bad69318c1c4d4413ea55ce7c5813f (patch) | |
| tree | 18b3b1cd5b4cf6b8eafed9779cf66f719b6e9081 /src/libsyntax/parse | |
| parent | ad8b437adabbc11e79c3672bd5c74294f38d3bc4 (diff) | |
| download | rust-6c728e32c0bad69318c1c4d4413ea55ce7c5813f.tar.gz rust-6c728e32c0bad69318c1c4d4413ea55ce7c5813f.zip | |
Parse (and discard) lifetime declarations on function types
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fce0948e711..799f0d40a46 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -307,12 +307,12 @@ pub impl Parser { { /* - extern "ABI" [pure|unsafe] fn (S) -> T - ^~~~^ ^~~~~~~~~~~~^ ^~^ ^ - | | | | - | | | Return type - | | Argument types - | | + extern "ABI" [pure|unsafe] fn <'lt> (S) -> T + ^~~~^ ^~~~~~~~~~~~^ ^~~~^ ^~^ ^ + | | | | | + | | | | Return type + | | | Argument types + | | Lifetimes | | | Purity ABI @@ -333,12 +333,12 @@ pub impl Parser { { /* - (&|~|@) [r/] [pure|unsafe] [once] fn (S) -> T - ^~~~~~^ ^~~^ ^~~~~~~~~~~~^ ^~~~~^ ^~^ ^ - | | | | | | - | | | | | Return type - | | | | Argument types - | | | | + (&|~|@) [r/] [pure|unsafe] [once] fn <'lt> (S) -> T + ^~~~~~^ ^~~^ ^~~~~~~~~~~~^ ^~~~~^ ^~~~^ ^~^ ^ + | | | | | | | + | | | | | | Return type + | | | | | Argument types + | | | | Lifetimes | | | Once-ness (a.k.a., affine) | | Purity | Lifetime bound @@ -394,12 +394,24 @@ pub impl Parser { } fn parse_ty_fn_decl() -> fn_decl { - let inputs = do self.parse_unspanned_seq( - token::LPAREN, token::RPAREN, - seq_sep_trailing_disallowed(token::COMMA)) |p| { + /* - p.parse_arg_general(false) - }; + (fn) <'lt> (S) -> T + ^~~~^ ^~^ ^ + | | | + | | Return type + | Argument types + Lifetimes + + */ + if self.eat(token::LT) { + let _lifetimes = self.parse_lifetimes(); + self.expect(token::GT); + } + let inputs = self.parse_unspanned_seq( + token::LPAREN, token::RPAREN, + seq_sep_trailing_disallowed(token::COMMA), + |p| p.parse_arg_general(false)); let (ret_style, ret_ty) = self.parse_ret_ty(); ast::fn_decl { inputs: inputs, output: ret_ty, cf: ret_style } } |
