about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-18 11:28:53 +0000
committerbors <bors@rust-lang.org>2015-01-18 11:28:53 +0000
commitdcaeb6aa23ecba2dc2af870668a9239136d20fa3 (patch)
treea1702f3eae2c0e1f487d1236271d0ec9f84403c8 /src/libsyntax/parse/parser.rs
parent30f081e54843952e34b0632e1b0ec54547bf6e3c (diff)
parentca8578a953d0563dbef499ea2c2c853c9b71887c (diff)
downloadrust-dcaeb6aa23ecba2dc2af870668a9239136d20fa3.tar.gz
rust-dcaeb6aa23ecba2dc2af870668a9239136d20fa3.zip
auto merge of #20901 : dgrunwald/rust/update-token-can-begin-expr, r=sanxiyn
 * add `Token::AndAnd` (double borrow)
 * add `Token::DotDot` (range notation)
 * remove `Token::Pound` and `Token::At`

This fixes a syntax error when parsing `fn f() -> RangeTo<i32> { return ..1; }`.

Also, remove `fn_expr_lookahead`.
It's from the `fn~` days and seems to no longer be necessary.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 30cc9836374..130972b4582 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2139,6 +2139,7 @@ impl<'a> Parser<'a> {
 
         let ex: Expr_;
 
+        // Note: when adding new syntax here, don't forget to adjust Token::can_begin_expr().
         match self.token {
             token::OpenDelim(token::Paren) => {
                 self.bump();
@@ -2776,6 +2777,7 @@ impl<'a> Parser<'a> {
         let lo = self.span.lo;
         let hi;
 
+        // Note: when adding new unary operators, don't forget to adjust Token::can_begin_expr()
         let ex;
         match self.token {
           token::Not => {
@@ -5536,13 +5538,6 @@ impl<'a> Parser<'a> {
         (id, ItemEnum(enum_definition, generics), None)
     }
 
-    fn fn_expr_lookahead(tok: &token::Token) -> bool {
-        match *tok {
-          token::OpenDelim(token::Paren) | token::At | token::Tilde | token::BinOp(_) => true,
-          _ => false
-        }
-    }
-
     /// Parses a string as an ABI spec on an extern type or module. Consumes
     /// the `extern` keyword, if one is found.
     fn parse_opt_abi(&mut self) -> Option<abi::Abi> {
@@ -5715,8 +5710,7 @@ impl<'a> Parser<'a> {
                                     maybe_append(attrs, extra_attrs));
             return IoviItem(item);
         }
-        if self.token.is_keyword(keywords::Fn) &&
-                self.look_ahead(1, |f| !Parser::fn_expr_lookahead(f)) {
+        if self.token.is_keyword(keywords::Fn) {
             // FUNCTION ITEM
             self.bump();
             let (ident, item_, extra_attrs) =