]> git.lizzy.rs Git - rust.git/commitdiff
Tweak some ‘expected…’ error messages
authorP1start <rewi-github@whanau.org>
Fri, 16 Jan 2015 03:04:28 +0000 (16:04 +1300)
committerP1start <rewi-github@whanau.org>
Mon, 2 Feb 2015 02:30:35 +0000 (15:30 +1300)
Fixes #21153.

20 files changed:
src/libsyntax/parse/attr.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/test/compile-fail/better-expected.rs
src/test/compile-fail/empty-impl-semicolon.rs
src/test/compile-fail/extern-no-fn.rs
src/test/compile-fail/issue-20711-2.rs
src/test/compile-fail/issue-20711.rs
src/test/compile-fail/issue-21153.rs [new file with mode: 0644]
src/test/compile-fail/multitrait.rs
src/test/compile-fail/pat-range-bad-dots.rs
src/test/compile-fail/removed-syntax-closure-lifetime.rs
src/test/compile-fail/removed-syntax-enum-newtype.rs
src/test/compile-fail/removed-syntax-extern-const.rs
src/test/compile-fail/removed-syntax-fixed-vec.rs
src/test/compile-fail/removed-syntax-mut-vec-ty.rs
src/test/compile-fail/removed-syntax-ptr-lifetime.rs
src/test/compile-fail/removed-syntax-static-fn.rs
src/test/compile-fail/removed-syntax-uniq-mut-ty.rs
src/test/compile-fail/struct-literal-in-match-discriminant.rs

index 54ec9c7b146d79b610c234a791a36f043d891e1b..06e8728d23672d101463d36144b5c9bee83c6be8 100644 (file)
@@ -13,7 +13,7 @@
 use codemap::{spanned, Spanned, mk_sp, Span};
 use parse::common::*; //resolve bug?
 use parse::token;
-use parse::parser::Parser;
+use parse::parser::{Parser, TokenType};
 use ptr::P;
 
 /// A parser that can parse attributes.
@@ -69,7 +69,9 @@ fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute {
                 let lo = self.span.lo;
                 self.bump();
 
-                let style = if self.eat(&token::Not) {
+                if permit_inner { self.expected_tokens.push(TokenType::Token(token::Not)); }
+                let style = if self.token == token::Not {
+                    self.bump();
                     if !permit_inner {
                         let span = self.span;
                         self.span_err(span,
@@ -96,7 +98,8 @@ fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute {
             }
         };
 
-        if permit_inner && self.eat(&token::Semi) {
+        if permit_inner && self.token == token::Semi {
+            self.bump();
             self.span_warn(span, "this inner attribute syntax is deprecated. \
                            The new syntax is `#![foo]`, with a bang and no semicolon");
             style = ast::AttrInner;
index d99095eeba37799be8df741502767973732cf712..66f5cdfd1e357acca2974408c1a04b445917a90c 100644 (file)
@@ -290,6 +290,7 @@ pub struct Parser<'a> {
 #[derive(PartialEq, Eq, Clone)]
 pub enum TokenType {
     Token(token::Token),
+    Keyword(keywords::Keyword),
     Operator,
 }
 
@@ -298,6 +299,7 @@ fn to_string(&self) -> String {
         match *self {
             TokenType::Token(ref t) => format!("`{}`", Parser::token_to_string(t)),
             TokenType::Operator => "an operator".to_string(),
+            TokenType::Keyword(kw) => format!("`{}`", token::get_name(kw.to_name())),
         }
     }
 }
@@ -365,9 +367,9 @@ pub fn unexpected_last(&self, t: &token::Token) -> ! {
                                                 token_str)[]);
     }
 
-    pub fn unexpected(&self) -> ! {
-        let this_token = self.this_token_to_string();
-        self.fatal(&format!("unexpected token: `{}`", this_token)[]);
+    pub fn unexpected(&mut self) -> ! {
+        self.expect_one_of(&[], &[]);
+        unreachable!()
     }
 
     /// Expect and consume the token t. Signal an error if
@@ -425,10 +427,13 @@ fn tokens_to_string(tokens: &[TokenType]) -> String {
             let expect = tokens_to_string(&expected[]);
             let actual = self.this_token_to_string();
             self.fatal(
-                &(if expected.len() != 1 {
+                &(if expected.len() > 1 {
                     (format!("expected one of {}, found `{}`",
                              expect,
                              actual))
+                } else if expected.len() == 0 {
+                    (format!("unexpected token: `{}`",
+                             actual))
                 } else {
                     (format!("expected {}, found `{}`",
                              expect,
@@ -515,7 +520,7 @@ pub fn parse_ident(&mut self) -> ast::Ident {
 
     pub fn parse_path_list_item(&mut self) -> ast::PathListItem {
         let lo = self.span.lo;
-        let node = if self.eat_keyword(keywords::Mod) {
+        let node = if self.eat_keyword_noexpect(keywords::Mod) {
             let span = self.last_span;
             self.span_warn(span, "deprecated syntax; use the `self` keyword now");
             ast::PathListMod { id: ast::DUMMY_NODE_ID }
@@ -547,9 +552,23 @@ pub fn eat(&mut self, tok: &token::Token) -> bool {
         is_present
     }
 
+    pub fn check_keyword(&mut self, kw: keywords::Keyword) -> bool {
+        self.expected_tokens.push(TokenType::Keyword(kw));
+        self.token.is_keyword(kw)
+    }
+
     /// If the next token is the given keyword, eat it and return
     /// true. Otherwise, return false.
     pub fn eat_keyword(&mut self, kw: keywords::Keyword) -> bool {
+        if self.check_keyword(kw) {
+            self.bump();
+            true
+        } else {
+            false
+        }
+    }
+
+    pub fn eat_keyword_noexpect(&mut self, kw: keywords::Keyword) -> bool {
         if self.token.is_keyword(kw) {
             self.bump();
             true
@@ -563,10 +582,7 @@ pub fn eat_keyword(&mut self, kw: keywords::Keyword) -> bool {
     /// Otherwise, eat it.
     pub fn expect_keyword(&mut self, kw: keywords::Keyword) {
         if !self.eat_keyword(kw) {
-            let id_interned_str = token::get_name(kw.to_name());
-            let token_str = self.this_token_to_string();
-            self.fatal(&format!("expected `{}`, found `{}`",
-                               id_interned_str, token_str)[])
+            self.expect_one_of(&[], &[]);
         }
     }
 
@@ -593,6 +609,7 @@ pub fn check_reserved_keywords(&mut self) {
     /// Expect and consume an `&`. If `&&` is seen, replace it with a single
     /// `&` and continue. If an `&` is not seen, signal an error.
     fn expect_and(&mut self) {
+        self.expected_tokens.push(TokenType::Token(token::BinOp(token::And)));
         match self.token {
             token::BinOp(token::And) => self.bump(),
             token::AndAnd => {
@@ -601,12 +618,7 @@ fn expect_and(&mut self) {
                 self.replace_token(token::BinOp(token::And), lo, span.hi)
             }
             _ => {
-                let token_str = self.this_token_to_string();
-                let found_token =
-                    Parser::token_to_string(&token::BinOp(token::And));
-                self.fatal(&format!("expected `{}`, found `{}`",
-                                   found_token,
-                                   token_str)[])
+                self.expect_one_of(&[], &[]);
             }
         }
     }
@@ -614,6 +626,7 @@ fn expect_and(&mut self) {
     /// Expect and consume a `|`. If `||` is seen, replace it with a single
     /// `|` and continue. If a `|` is not seen, signal an error.
     fn expect_or(&mut self) {
+        self.expected_tokens.push(TokenType::Token(token::BinOp(token::Or)));
         match self.token {
             token::BinOp(token::Or) => self.bump(),
             token::OrOr => {
@@ -622,12 +635,7 @@ fn expect_or(&mut self) {
                 self.replace_token(token::BinOp(token::Or), lo, span.hi)
             }
             _ => {
-                let found_token = self.this_token_to_string();
-                let token_str =
-                    Parser::token_to_string(&token::BinOp(token::Or));
-                self.fatal(&format!("expected `{}`, found `{}`",
-                                   token_str,
-                                   found_token)[])
+                self.expect_one_of(&[], &[]);
             }
         }
     }
@@ -652,6 +660,7 @@ pub fn expect_no_suffix(&self, sp: Span, kind: &str, suffix: Option<ast::Name>)
     /// This is meant to be used when parsing generics on a path to get the
     /// starting token.
     fn eat_lt(&mut self) -> bool {
+        self.expected_tokens.push(TokenType::Token(token::Lt));
         match self.token {
             token::Lt => { self.bump(); true }
             token::BinOp(token::Shl) => {
@@ -666,11 +675,7 @@ fn eat_lt(&mut self) -> bool {
 
     fn expect_lt(&mut self) {
         if !self.eat_lt() {
-            let found_token = self.this_token_to_string();
-            let token_str = Parser::token_to_string(&token::Lt);
-            self.fatal(&format!("expected `{}`, found `{}`",
-                               token_str,
-                               found_token)[])
+            self.expect_one_of(&[], &[]);
         }
     }
 
@@ -700,6 +705,7 @@ fn parse_seq_to_before_or<T, F>(&mut self,
     /// with a single > and continue. If a GT is not seen,
     /// signal an error.
     pub fn expect_gt(&mut self) {
+        self.expected_tokens.push(TokenType::Token(token::Gt));
         match self.token {
             token::Gt => self.bump(),
             token::BinOp(token::Shr) => {
@@ -998,14 +1004,14 @@ pub fn id_to_interned_str(&mut self, id: Ident) -> InternedString {
     /// Is the current token one of the keywords that signals a bare function
     /// type?
     pub fn token_is_bare_fn_keyword(&mut self) -> bool {
-        self.token.is_keyword(keywords::Fn) ||
-            self.token.is_keyword(keywords::Unsafe) ||
-            self.token.is_keyword(keywords::Extern)
+        self.check_keyword(keywords::Fn) ||
+            self.check_keyword(keywords::Unsafe) ||
+            self.check_keyword(keywords::Extern)
     }
 
     /// Is the current token one of the keywords that signals a closure type?
     pub fn token_is_closure_keyword(&mut self) -> bool {
-        self.token.is_keyword(keywords::Unsafe)
+        self.check_keyword(keywords::Unsafe)
     }
 
     pub fn get_lifetime(&mut self) -> ast::Ident {
@@ -1035,7 +1041,7 @@ pub fn parse_for_in_type(&mut self) -> Ty_ {
         let lifetime_defs = self.parse_late_bound_lifetime_defs();
 
         // examine next token to decide to do
-        if self.eat_keyword(keywords::Proc) {
+        if self.eat_keyword_noexpect(keywords::Proc) {
             self.parse_proc_type(lifetime_defs)
         } else if self.token_is_bare_fn_keyword() || self.token_is_closure_keyword() {
             self.parse_ty_bare_fn_or_ty_closure(lifetime_defs)
@@ -1166,11 +1172,11 @@ pub fn parse_ty_bare_fn_or_ty_closure(&mut self, lifetime_defs: Vec<LifetimeDef>
         // Closure:  [unsafe] <'lt> |S| [:Bounds] -> T
         // Fn:       [unsafe] [extern "ABI"] fn <'lt> (S) -> T
 
-        if self.token.is_keyword(keywords::Fn) {
+        if self.check_keyword(keywords::Fn) {
             self.parse_ty_bare_fn(lifetime_defs)
-        } else if self.token.is_keyword(keywords::Extern) {
+        } else if self.check_keyword(keywords::Extern) {
             self.parse_ty_bare_fn(lifetime_defs)
-        } else if self.token.is_keyword(keywords::Unsafe) {
+        } else if self.check_keyword(keywords::Unsafe) {
             if self.look_ahead(1, |t| t.is_keyword(keywords::Fn) ||
                                       t.is_keyword(keywords::Extern)) {
                 self.parse_ty_bare_fn(lifetime_defs)
@@ -1480,7 +1486,7 @@ pub fn parse_ty(&mut self) -> P<Ty> {
             // BORROWED POINTER
             self.expect_and();
             self.parse_borrowed_pointee()
-        } else if self.token.is_keyword(keywords::For) {
+        } else if self.check_keyword(keywords::For) {
             self.parse_for_in_type()
         } else if self.token_is_bare_fn_keyword() ||
                   self.token_is_closure_keyword() {
@@ -1494,14 +1500,14 @@ pub fn parse_ty(&mut self) -> P<Ty> {
                    })) {
             // CLOSURE
             self.parse_ty_closure(Vec::new())
-        } else if self.eat_keyword(keywords::Typeof) {
+        } else if self.eat_keyword_noexpect(keywords::Typeof) {
             // TYPEOF
             // In order to not be ambiguous, the type must be surrounded by parens.
             self.expect(&token::OpenDelim(token::Paren));
             let e = self.parse_expr();
             self.expect(&token::CloseDelim(token::Paren));
             TyTypeof(e)
-        } else if self.eat_keyword(keywords::Proc) {
+        } else if self.eat_keyword_noexpect(keywords::Proc) {
             self.parse_proc_type(Vec::new())
         } else if self.eat_lt() {
             // QUALIFIED PATH `<TYPE as TRAIT_REF>::item`
@@ -2092,6 +2098,7 @@ pub fn mk_lit_u32(&mut self, i: u32) -> P<Expr> {
     }
 
     fn expect_open_delim(&mut self) -> token::DelimToken {
+        self.expected_tokens.push(TokenType::Token(token::Gt));
         match self.token {
             token::OpenDelim(delim) => {
                 self.bump();
@@ -2233,7 +2240,7 @@ pub fn parse_bottom_expr(&mut self) -> P<Expr> {
                 if self.eat_keyword(keywords::Move) {
                     return self.parse_lambda_expr(CaptureByValue);
                 }
-                if self.eat_keyword(keywords::Proc) {
+                if self.eat_keyword_noexpect(keywords::Proc) {
                     let span = self.last_span;
                     let _ = self.parse_proc_decl();
                     let _ = self.parse_expr();
@@ -2307,8 +2314,8 @@ pub fn parse_bottom_expr(&mut self) -> P<Expr> {
                     hi = self.span.hi;
                 } else if self.check(&token::ModSep) ||
                         self.token.is_ident() &&
-                        !self.token.is_keyword(keywords::True) &&
-                        !self.token.is_keyword(keywords::False) {
+                        !self.check_keyword(keywords::True) &&
+                        !self.check_keyword(keywords::False) {
                     let pth =
                         self.parse_path(LifetimeAndTypesWithColons);
 
@@ -2792,7 +2799,7 @@ pub fn parse_prefix_expr(&mut self) -> P<Expr> {
             ex = ExprAddrOf(m, e);
           }
           token::Ident(_, _) => {
-            if !self.token.is_keyword(keywords::Box) {
+            if !self.check_keyword(keywords::Box) {
                 return self.parse_dot_or_call_expr();
             }
 
@@ -2879,7 +2886,7 @@ pub fn parse_more_binops(&mut self, lhs: P<Expr>, min_prec: usize) -> P<Expr> {
                 }
             }
             None => {
-                if AS_PREC >= min_prec && self.eat_keyword(keywords::As) {
+                if AS_PREC >= min_prec && self.eat_keyword_noexpect(keywords::As) {
                     let rhs = self.parse_ty();
                     let _as = self.mk_expr(lhs.span.lo,
                                            rhs.span.hi,
@@ -3002,7 +3009,7 @@ fn is_at_start_of_range_notation_rhs(&self) -> bool {
 
     /// Parse an 'if' or 'if let' expression ('if' token already eaten)
     pub fn parse_if_expr(&mut self) -> P<Expr> {
-        if self.token.is_keyword(keywords::Let) {
+        if self.check_keyword(keywords::Let) {
             return self.parse_if_let_expr();
         }
         let lo = self.last_span.lo;
@@ -3655,7 +3662,7 @@ fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
         }
 
         let lo = self.span.lo;
-        if self.token.is_keyword(keywords::Let) {
+        if self.check_keyword(keywords::Let) {
             check_expected_item(self, &item_attrs[]);
             self.expect_keyword(keywords::Let);
             let decl = self.parse_let();
@@ -5302,7 +5309,7 @@ fn parse_item_extern_crate(&mut self,
         let (maybe_path, ident) = match self.token {
             token::Ident(..) => {
                 let the_ident = self.parse_ident();
-                let path = if self.eat_keyword(keywords::As) {
+                let path = if self.eat_keyword_noexpect(keywords::As) {
                     // skip the ident if there is one
                     if self.token.is_ident() { self.bump(); }
 
@@ -5595,14 +5602,13 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     token_str)[]);
         }
 
-        if self.eat_keyword(keywords::Virtual) {
+        if self.eat_keyword_noexpect(keywords::Virtual) {
             let span = self.span;
             self.span_err(span, "`virtual` structs have been removed from the language");
         }
 
-        if self.token.is_keyword(keywords::Static) {
+        if self.eat_keyword(keywords::Static) {
             // STATIC ITEM
-            self.bump();
             let m = if self.eat_keyword(keywords::Mut) {MutMutable} else {MutImmutable};
             let (ident, item_, extra_attrs) = self.parse_item_const(Some(m));
             let last_span = self.last_span;
@@ -5614,9 +5620,8 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     maybe_append(attrs, extra_attrs));
             return Ok(item);
         }
-        if self.token.is_keyword(keywords::Const) {
+        if self.eat_keyword(keywords::Const) {
             // CONST ITEM
-            self.bump();
             if self.eat_keyword(keywords::Mut) {
                 let last_span = self.last_span;
                 self.span_err(last_span, "const globals cannot be mutable");
@@ -5632,7 +5637,7 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     maybe_append(attrs, extra_attrs));
             return Ok(item);
         }
-        if self.token.is_keyword(keywords::Unsafe) &&
+        if self.check_keyword(keywords::Unsafe) &&
             self.look_ahead(1us, |t| t.is_keyword(keywords::Trait))
         {
             // UNSAFE TRAIT ITEM
@@ -5649,7 +5654,7 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     maybe_append(attrs, extra_attrs));
             return Ok(item);
         }
-        if self.token.is_keyword(keywords::Unsafe) &&
+        if self.check_keyword(keywords::Unsafe) &&
             self.look_ahead(1us, |t| t.is_keyword(keywords::Impl))
         {
             // IMPL ITEM
@@ -5665,7 +5670,7 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     maybe_append(attrs, extra_attrs));
             return Ok(item);
         }
-        if self.token.is_keyword(keywords::Fn) {
+        if self.check_keyword(keywords::Fn) {
             // FUNCTION ITEM
             self.bump();
             let (ident, item_, extra_attrs) =
@@ -5679,7 +5684,7 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     maybe_append(attrs, extra_attrs));
             return Ok(item);
         }
-        if self.token.is_keyword(keywords::Unsafe)
+        if self.check_keyword(keywords::Unsafe)
             && self.look_ahead(1us, |t| *t != token::OpenDelim(token::Brace)) {
             // UNSAFE FUNCTION ITEM
             self.bump();
@@ -5784,11 +5789,11 @@ fn parse_foreign_item(&mut self, attrs: Vec<Attribute>)
 
         let visibility = self.parse_visibility();
 
-        if self.token.is_keyword(keywords::Static) {
+        if self.check_keyword(keywords::Static) {
             // FOREIGN STATIC ITEM
             return Ok(self.parse_item_foreign_static(visibility, attrs));
         }
-        if self.token.is_keyword(keywords::Fn) || self.token.is_keyword(keywords::Unsafe) {
+        if self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) {
             // FOREIGN FUNCTION ITEM
             return Ok(self.parse_item_foreign_fn(visibility, attrs));
         }
index 5531ce7b119eb83ef27406607314315d4bf5a8ae..5c3892e49c0587543e02f334921741b971db5f39 100644 (file)
@@ -456,7 +456,7 @@ pub mod keywords {
         pub use self::Keyword::*;
         use ast;
 
-        #[derive(Copy)]
+        #[derive(Copy, Clone, PartialEq, Eq)]
         pub enum Keyword {
             $( $sk_variant, )*
             $( $rk_variant, )*
index 0d84a5e7d0280bffdde45f64d69385013857fb2a..e07f4b8e549008db0911a2d12d741d390cc86ac2 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn main() {
-    let x: [isize 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `3`
+    let x: [isize 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
 }
index a598252f1b65e99c20e45a23594c19aa44283862..70c7d42feb53f063c3094c815a97ec25034b9b94 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-impl Foo; //~ ERROR expected one of `(`, `+`, `::`, or `{`, found `;`
+impl Foo; //~ ERROR expected one of `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;`
index 164cbe5417402dd619c597b71243b46706fc55b0..69e2f3ae60be5c02ace2dfc4b79c587165a6868c 100644 (file)
@@ -8,9 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:unexpected token
 extern {
-    f();
+    f(); //~ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `f`
 }
 
 fn main() {
index 9f0e81a662f55c38a0190140a8a623ceb498c89b..a6c4570c60f7f93d7862d086f1bfabb4cbc9a5c1 100644 (file)
@@ -14,7 +14,7 @@ impl Foo {
     fn foo() {}
 
     #[stable(feature = "rust1", since = "1.0.0")]
-} //~ ERROR expected `fn`, found `}`
+} //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`
 
 fn main() {}
 
index 5f0f0fc05a929372e32b797533f81630d35a64ef..3b329d78237491a491a42020fc67083cc3829a3f 100644 (file)
@@ -12,6 +12,6 @@
 
 impl Foo {
     #[stable(feature = "rust1", since = "1.0.0")]
-} //~ ERROR expected `fn`, found `}`
+} //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-21153.rs b/src/test/compile-fail/issue-21153.rs
new file mode 100644 (file)
index 0000000..e2b6deb
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+trait MyTrait<T>: Iterator {
+    Item = T; //~ ERROR expected one of `extern`, `fn`, `pub`, `type`, or `unsafe`, found `Item`
+}
index a0e210aed40e6bdfb3a58eaf6cfe862f6f3bb1fb..f182eb8fa5ba6bb7f77f84e7eb80f39245500773 100644 (file)
@@ -12,7 +12,8 @@ struct S {
  y: isize
 }
 
-impl Cmp, ToString for S { //~ ERROR: expected one of `(`, `+`, `::`, or `{`, found `,`
+impl Cmp, ToString for S {
+//~^ ERROR: expected one of `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `,`
   fn eq(&&other: S) { false }
   fn to_string(&self) -> String { "hi".to_string() }
 }
index b48d3e8871b203b04b4ecb92de42da3c491f0da5..c52fb8c9b67979cf55c412ca91d145981ace7fa5 100644 (file)
@@ -10,7 +10,7 @@
 
 pub fn main() {
     match 22 {
-        0 .. 3 => {} //~ ERROR expected one of `...`, `=>`, or `|`, found `..`
+        0 .. 3 => {} //~ ERROR expected one of `...`, `=>`, `if`, or `|`, found `..`
         _ => {}
     }
 }
index a07832d5bb7614e3e5de56a819a2b297dac55989..0cea87dba19bbba306bd531223fff888ed20056e 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-type closure = Box<lt/fn()>; //~ ERROR expected one of `(`, `+`, `,`, `::`, or `>`, found `/`
+type closure = Box<lt/fn()>; //~ ERROR expected one of `(`, `+`, `,`, `::`, `<`, or `>`, found `/`
index 3b45fd81288fd99ffa5597edc784bf06359ce217..b067cee03d257a07bbe0e57651fe824e8ffb25e0 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum e = isize; //~ ERROR expected one of `<` or `{`, found `=`
+enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=`
index 98eec0977e0c173bbd32f5c26f1217905bbc2ae9..a0e1d04a3dc5d098d34d41f29c7776f29e8fa4e5 100644 (file)
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 extern {
-    const i: isize; //~ ERROR unexpected token: `const`
+    const i: isize;
+    //~^ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `const`
 }
index 0ca2380ef68c7c365cf85eb7945cac6cd0ca406b..0e8e20b38918724cc2cf384a0d2ee8b19088e5f9 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-type v = [isize * 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `*`
+type v = [isize * 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `*`
index 0f67a1d04eec3885746e5b0c94ae49967c6e98aa..9a7570a92f002ace9a002b1bb505f9f844bc1fc2 100644 (file)
@@ -10,4 +10,4 @@
 
 type v = [mut isize];
     //~^  ERROR expected identifier, found keyword `mut`
-    //~^^ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `isize`
+    //~^^ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `isize`
index d94f2ec1e073e84a2561e230397729fd6011439a..44c65d98c0b7201ad46949ddae0a77dddbc80198 100644 (file)
@@ -8,4 +8,4 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-type bptr = &lifetime/isize; //~ ERROR expected one of `(`, `+`, `::`, or `;`, found `/`
+type bptr = &lifetime/isize; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `<`, found `/`
index e3e1cb0f3cac89dd4382828062883174f0e8b66d..caf939e7b8aa9d039755e514b7579fa44b3f9af7 100644 (file)
@@ -11,5 +11,6 @@
 struct S;
 
 impl S {
-    static fn f() {} //~ ERROR expected `fn`, found `static`
+    static fn f() {}
+    //~^ ERROR expected one of `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static`
 }
index c051059aee6f45951fc71a1c63d7f9533fe0d9cb..d1c2fc69f523383354671b838aa8182a57e3ee3c 100644 (file)
@@ -10,4 +10,4 @@
 
 type mut_box = Box<mut isize>;
     //~^  ERROR expected identifier, found keyword `mut`
-    //~^^ ERROR expected one of `(`, `+`, `,`, `::`, or `>`, found `isize`
+    //~^^ ERROR expected one of `(`, `+`, `,`, `::`, `<`, or `>`, found `isize`
index 8f50940806a589a3c8feca1f84c2bb54b84ef806..e6948b7c7c99580145f650518df52725ecfb6aa1 100644 (file)
@@ -14,7 +14,7 @@ struct Foo {
 
 fn main() {
     match Foo {
-        x: 3    //~ ERROR expected one of `!`, `=>`, `@`, or `|`, found `:`
+        x: 3    //~ ERROR expected one of `!`, `=>`, `@`, `if`, or `|`, found `:`
     } {
         Foo {
             x: x