Tweak more warnings.

Much like the previous commit.

I think the removal of "the token" in each message is fine here. There
are many more error messages that mention tokens without saying "the
token" than those that do say it.
This commit is contained in:
Nicholas Nethercote 2024-06-25 12:52:15 +10:00
parent a201fab208
commit dd2b027d5d
50 changed files with 113 additions and 121 deletions

View File

@ -2,10 +2,9 @@ use std::borrow::Cow;
use rustc_ast::token::{self, Token, TokenKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, DiagMessage};
use rustc_macros::Subdiagnostic;
use rustc_parse::parser::{Parser, Recovery};
use rustc_parse::parser::{Parser, Recovery, token_descr};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::Ident;
@ -336,17 +335,11 @@ pub(super) fn annotate_doc_comment(err: &mut Diag<'_>, sm: &SourceMap, span: Spa
/// other tokens, this is "unexpected token...".
pub(super) fn parse_failure_msg(tok: &Token, expected_token: Option<&Token>) -> Cow<'static, str> {
if let Some(expected_token) = expected_token {
Cow::from(format!(
"expected `{}`, found `{}`",
pprust::token_to_string(expected_token),
pprust::token_to_string(tok),
))
Cow::from(format!("expected {}, found {}", token_descr(expected_token), token_descr(tok)))
} else {
match tok.kind {
token::Eof => Cow::from("unexpected end of macro invocation"),
_ => {
Cow::from(format!("no rules expected the token `{}`", pprust::token_to_string(tok)))
}
_ => Cow::from(format!("no rules expected {}", token_descr(tok))),
}
}
}

View File

@ -78,11 +78,10 @@ use std::rc::Rc;
pub(crate) use NamedMatch::*;
pub(crate) use ParseResult::*;
use rustc_ast::token::{self, DocComment, NonterminalKind, Token};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed;
use rustc_lint_defs::pluralize;
use rustc_parse::parser::{ParseNtResult, Parser};
use rustc_parse::parser::{ParseNtResult, Parser, token_descr};
use rustc_span::Span;
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
@ -150,7 +149,7 @@ impl Display for MatcherLoc {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MatcherLoc::Token { token } | MatcherLoc::SequenceSep { separator: token } => {
write!(f, "`{}`", pprust::token_to_string(token))
write!(f, "{}", token_descr(token))
}
MatcherLoc::MetaVarDecl { bind, kind, .. } => {
write!(f, "meta-variable `${bind}")?;

View File

@ -1,3 +1,3 @@
pub fn main() {
vec![,]; //~ ERROR no rules expected the token `,`
vec![,]; //~ ERROR no rules expected `,`
}

View File

@ -1,4 +1,4 @@
error: no rules expected the token `,`
error: no rules expected `,`
--> $DIR/vec-macro-with-comma-only.rs:2:10
|
LL | vec![,];

View File

@ -13,8 +13,8 @@ pub fn check_async() {
let mut r#async = 1; // OK
r#async = consumes_async!(async); // OK
r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
r#async = consumes_async!(r#async); //~ ERROR no rules expected `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected `async`
r#async = consumes_async_raw!(r#async); // OK
if passes_ident!(async) == 1 {} // OK

View File

@ -1,4 +1,4 @@
error: no rules expected the token `r#async`
error: no rules expected `r#async`
--> $DIR/edition-keywords-2015-2015-parsing.rs:16:31
|
LL | r#async = consumes_async!(r#async);
@ -10,7 +10,7 @@ note: while trying to match `async`
LL | (async) => (1)
| ^^^^^
error: no rules expected the token `async`
error: no rules expected `async`
--> $DIR/edition-keywords-2015-2015-parsing.rs:17:35
|
LL | r#async = consumes_async_raw!(async);

View File

@ -13,8 +13,8 @@ pub fn check_async() {
let mut r#async = 1; // OK
r#async = consumes_async!(async); // OK
r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
r#async = consumes_async!(r#async); //~ ERROR no rules expected `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected `async`
r#async = consumes_async_raw!(r#async); // OK
if passes_ident!(async) == 1 {} // OK

View File

@ -1,4 +1,4 @@
error: no rules expected the token `r#async`
error: no rules expected `r#async`
--> $DIR/edition-keywords-2015-2018-parsing.rs:16:31
|
LL | r#async = consumes_async!(r#async);
@ -10,7 +10,7 @@ note: while trying to match `async`
LL | (async) => (1)
| ^^^^^
error: no rules expected the token `async`
error: no rules expected `async`
--> $DIR/edition-keywords-2015-2018-parsing.rs:17:35
|
LL | r#async = consumes_async_raw!(async);

View File

@ -17,8 +17,8 @@ pub fn check_async() {
let mut r#async = 1; // OK
r#async = consumes_async!(async); // OK
r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
r#async = consumes_async!(r#async); //~ ERROR no rules expected `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected keyword `async`
r#async = consumes_async_raw!(r#async); // OK
if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved

View File

@ -20,19 +20,19 @@ help: escape `async` to use it as an identifier
LL | module::r#async();
| ++
error: no rules expected the token `r#async`
error: no rules expected `r#async`
--> $DIR/edition-keywords-2018-2015-parsing.rs:20:31
|
LL | r#async = consumes_async!(r#async);
| ^^^^^^^ no rules expected this token in macro call
|
note: while trying to match `async`
note: while trying to match keyword `async`
--> $DIR/auxiliary/edition-kw-macro-2015.rs:17:6
|
LL | (async) => (1)
| ^^^^^
error: no rules expected the token `async`
error: no rules expected keyword `async`
--> $DIR/edition-keywords-2018-2015-parsing.rs:21:35
|
LL | r#async = consumes_async_raw!(async);

View File

@ -24,8 +24,8 @@ pub fn check_async() {
let mut r#async = 1; // OK
r#async = consumes_async!(async); // OK
r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
r#async = consumes_async!(r#async); //~ ERROR no rules expected `r#async`
r#async = consumes_async_raw!(async); //~ ERROR no rules expected keyword `async`
r#async = consumes_async_raw!(r#async); // OK
if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved

View File

@ -20,19 +20,19 @@ help: escape `async` to use it as an identifier
LL | module::r#async();
| ++
error: no rules expected the token `r#async`
error: no rules expected `r#async`
--> $DIR/edition-keywords-2018-2018-parsing.rs:27:31
|
LL | r#async = consumes_async!(r#async);
| ^^^^^^^ no rules expected this token in macro call
|
note: while trying to match `async`
note: while trying to match keyword `async`
--> $DIR/auxiliary/edition-kw-macro-2018.rs:17:6
|
LL | (async) => (1)
| ^^^^^
error: no rules expected the token `async`
error: no rules expected keyword `async`
--> $DIR/edition-keywords-2018-2018-parsing.rs:28:35
|
LL | r#async = consumes_async_raw!(async);

View File

@ -1,3 +1,3 @@
fn main() {
panic!(@); //~ ERROR no rules expected the token `@`
panic!(@); //~ ERROR no rules expected `@`
}

View File

@ -1,4 +1,4 @@
error: no rules expected the token `@`
error: no rules expected `@`
--> $DIR/fail-simple.rs:2:12
|
LL | panic!(@);

View File

@ -10,7 +10,7 @@ error: expected one of `,`, `.`, `?`, or an operator, found `some`
LL | assert!(true some extra junk);
| ^^^^ expected one of `,`, `.`, `?`, or an operator
error: no rules expected the token `blah`
error: no rules expected `blah`
--> $DIR/assert-trailing-junk.rs:15:30
|
LL | assert!(true, "whatever" blah);
@ -28,7 +28,7 @@ LL | assert!(true "whatever" blah);
| |
| help: try adding a comma
error: no rules expected the token `blah`
error: no rules expected `blah`
--> $DIR/assert-trailing-junk.rs:18:29
|
LL | assert!(true "whatever" blah);

View File

@ -10,7 +10,7 @@ error: expected one of `,`, `.`, `?`, or an operator, found `some`
LL | assert!(true some extra junk);
| ^^^^ expected one of `,`, `.`, `?`, or an operator
error: no rules expected the token `blah`
error: no rules expected `blah`
--> $DIR/assert-trailing-junk.rs:15:30
|
LL | assert!(true, "whatever" blah);
@ -28,7 +28,7 @@ LL | assert!(true "whatever" blah);
| |
| help: try adding a comma
error: no rules expected the token `blah`
error: no rules expected `blah`
--> $DIR/assert-trailing-junk.rs:18:29
|
LL | assert!(true "whatever" blah);

View File

@ -2,7 +2,7 @@ macro_rules! number {
(neg false, $self:ident) => { $self };
($signed:tt => $ty:ty;) => {
number!(neg $signed, $self);
//~^ ERROR no rules expected the token `$`
//~^ ERROR no rules expected `$`
};
}

View File

@ -1,4 +1,4 @@
error: no rules expected the token `$`
error: no rules expected `$`
--> $DIR/best-failure.rs:4:30
|
LL | macro_rules! number {

View File

@ -1,4 +1,4 @@
error: no rules expected the token `const`
error: no rules expected keyword `const`
--> $DIR/expr_2021_inline_const.rs:23:12
|
LL | macro_rules! m2021 {
@ -13,7 +13,7 @@ note: while trying to match meta-variable `$e:expr_2021`
LL | ($e:expr_2021) => {
| ^^^^^^^^^^^^
error: no rules expected the token `const`
error: no rules expected keyword `const`
--> $DIR/expr_2021_inline_const.rs:24:12
|
LL | macro_rules! m2024 {

View File

@ -1,4 +1,4 @@
error: no rules expected the token `const`
error: no rules expected keyword `const`
--> $DIR/expr_2021_inline_const.rs:23:12
|
LL | macro_rules! m2021 {

View File

@ -20,8 +20,8 @@ macro_rules! test {
}
fn main() {
m2021!(const { 1 }); //~ ERROR: no rules expected the token `const`
m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected the token `const`
m2021!(const { 1 }); //~ ERROR: no rules expected keyword `const`
m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected keyword `const`
test!(expr);
}

View File

@ -1,4 +1,4 @@
error: no rules expected the token `_`
error: no rules expected reserved identifier `_`
--> $DIR/expr_2024_underscore_expr.rs:19:12
|
LL | macro_rules! m2021 {
@ -13,7 +13,7 @@ note: while trying to match meta-variable `$e:expr_2021`
LL | ($e:expr_2021) => {
| ^^^^^^^^^^^^
error: no rules expected the token `_`
error: no rules expected reserved identifier `_`
--> $DIR/expr_2024_underscore_expr.rs:20:12
|
LL | macro_rules! m2024 {

View File

@ -1,4 +1,4 @@
error: no rules expected the token `_`
error: no rules expected reserved identifier `_`
--> $DIR/expr_2024_underscore_expr.rs:19:12
|
LL | macro_rules! m2021 {

View File

@ -16,6 +16,6 @@ macro_rules! m2024 {
}
fn main() {
m2021!(_); //~ ERROR: no rules expected the token `_`
m2024!(_); //[edi2021]~ ERROR: no rules expected the token `_`
m2021!(_); //~ ERROR: no rules expected reserved identifier `_`
m2024!(_); //[edi2021]~ ERROR: no rules expected reserved identifier `_`
}

View File

@ -22,21 +22,21 @@ macro_rules! barstar {
pub fn main() {
foo!();
foo!(a);
foo!(a?); //~ ERROR no rules expected the token `?`
foo!(a?a); //~ ERROR no rules expected the token `?`
foo!(a?a?a); //~ ERROR no rules expected the token `?`
foo!(a?); //~ ERROR no rules expected `?`
foo!(a?a); //~ ERROR no rules expected `?`
foo!(a?a?a); //~ ERROR no rules expected `?`
barplus!(); //~ERROR unexpected end of macro invocation
barplus!(a); //~ERROR unexpected end of macro invocation
barplus!(a?); //~ ERROR no rules expected the token `?`
barplus!(a?a); //~ ERROR no rules expected the token `?`
barplus!(a?); //~ ERROR no rules expected `?`
barplus!(a?a); //~ ERROR no rules expected `?`
barplus!(a+);
barplus!(+);
barstar!(); //~ERROR unexpected end of macro invocation
barstar!(a); //~ERROR unexpected end of macro invocation
barstar!(a?); //~ ERROR no rules expected the token `?`
barstar!(a?a); //~ ERROR no rules expected the token `?`
barstar!(a?); //~ ERROR no rules expected `?`
barstar!(a?a); //~ ERROR no rules expected `?`
barstar!(a*);
barstar!(*);
}

View File

@ -4,7 +4,7 @@ error: the `?` macro repetition operator does not take a separator
LL | ($(a),?) => {};
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:25:11
|
LL | macro_rules! foo {
@ -15,7 +15,7 @@ LL | foo!(a?);
|
= note: while trying to match sequence end
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:26:11
|
LL | macro_rules! foo {
@ -26,7 +26,7 @@ LL | foo!(a?a);
|
= note: while trying to match sequence end
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:27:11
|
LL | macro_rules! foo {
@ -67,7 +67,7 @@ note: while trying to match `+`
LL | ($(a)?+) => {}; // ok. matches "a+" and "+"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:31:15
|
LL | macro_rules! barplus {
@ -82,7 +82,7 @@ note: while trying to match `+`
LL | ($(a)?+) => {}; // ok. matches "a+" and "+"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:32:15
|
LL | macro_rules! barplus {
@ -127,7 +127,7 @@ note: while trying to match `*`
LL | ($(a)?*) => {}; // ok. matches "a*" and "*"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:38:15
|
LL | macro_rules! barstar {
@ -142,7 +142,7 @@ note: while trying to match `*`
LL | ($(a)?*) => {}; // ok. matches "a*" and "*"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2015.rs:39:15
|
LL | macro_rules! barstar {

View File

@ -22,21 +22,21 @@ macro_rules! barstar {
pub fn main() {
foo!();
foo!(a);
foo!(a?); //~ ERROR no rules expected the token `?`
foo!(a?a); //~ ERROR no rules expected the token `?`
foo!(a?a?a); //~ ERROR no rules expected the token `?`
foo!(a?); //~ ERROR no rules expected `?`
foo!(a?a); //~ ERROR no rules expected `?`
foo!(a?a?a); //~ ERROR no rules expected `?`
barplus!(); //~ERROR unexpected end of macro invocation
barplus!(a); //~ERROR unexpected end of macro invocation
barplus!(a?); //~ ERROR no rules expected the token `?`
barplus!(a?a); //~ ERROR no rules expected the token `?`
barplus!(a?); //~ ERROR no rules expected `?`
barplus!(a?a); //~ ERROR no rules expected `?`
barplus!(a+);
barplus!(+);
barstar!(); //~ERROR unexpected end of macro invocation
barstar!(a); //~ERROR unexpected end of macro invocation
barstar!(a?); //~ ERROR no rules expected the token `?`
barstar!(a?a); //~ ERROR no rules expected the token `?`
barstar!(a?); //~ ERROR no rules expected `?`
barstar!(a?a); //~ ERROR no rules expected `?`
barstar!(a*);
barstar!(*);
}

View File

@ -4,7 +4,7 @@ error: the `?` macro repetition operator does not take a separator
LL | ($(a),?) => {};
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:25:11
|
LL | macro_rules! foo {
@ -15,7 +15,7 @@ LL | foo!(a?);
|
= note: while trying to match sequence end
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:26:11
|
LL | macro_rules! foo {
@ -26,7 +26,7 @@ LL | foo!(a?a);
|
= note: while trying to match sequence end
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:27:11
|
LL | macro_rules! foo {
@ -67,7 +67,7 @@ note: while trying to match `+`
LL | ($(a)?+) => {}; // ok. matches "a+" and "+"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:31:15
|
LL | macro_rules! barplus {
@ -82,7 +82,7 @@ note: while trying to match `+`
LL | ($(a)?+) => {}; // ok. matches "a+" and "+"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:32:15
|
LL | macro_rules! barplus {
@ -127,7 +127,7 @@ note: while trying to match `*`
LL | ($(a)?*) => {}; // ok. matches "a*" and "*"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:38:15
|
LL | macro_rules! barstar {
@ -142,7 +142,7 @@ note: while trying to match `*`
LL | ($(a)?*) => {}; // ok. matches "a*" and "*"
| ^
error: no rules expected the token `?`
error: no rules expected `?`
--> $DIR/macro-at-most-once-rep-2018.rs:39:15
|
LL | macro_rules! barstar {

View File

@ -4,5 +4,5 @@ macro_rules! m { ($x:lifetime) => { } }
fn main() {
m!(a);
//~^ ERROR no rules expected the token `a`
//~^ ERROR no rules expected `a`
}

View File

@ -1,4 +1,4 @@
error: no rules expected the token `a`
error: no rules expected `a`
--> $DIR/macro-non-lifetime.rs:6:8
|
LL | macro_rules! m { ($x:lifetime) => { } }

View File

@ -19,16 +19,16 @@ fn main() {
println!("{}" a);
//~^ ERROR expected `,`, found `a`
foo!(a b);
//~^ ERROR no rules expected the token `b`
//~^ ERROR no rules expected `b`
foo!(a, b, c, d e);
//~^ ERROR no rules expected the token `e`
//~^ ERROR no rules expected `e`
foo!(a, b, c d, e);
//~^ ERROR no rules expected the token `d`
//~^ ERROR no rules expected `d`
foo!(a, b, c d e);
//~^ ERROR no rules expected the token `d`
//~^ ERROR no rules expected `d`
bar!(Level::Error, );
//~^ ERROR unexpected end of macro invocation
check!(<str as Debug>::fmt, "fmt");
check!(<str as Debug>::fmt, "fmt",);
//~^ ERROR no rules expected the token `,`
//~^ ERROR no rules expected `,`
}

View File

@ -4,7 +4,7 @@ error: expected `,`, found `a`
LL | println!("{}" a);
| ^ expected `,`
error: no rules expected the token `b`
error: no rules expected `b`
--> $DIR/missing-comma.rs:21:12
|
LL | macro_rules! foo {
@ -21,7 +21,7 @@ note: while trying to match meta-variable `$a:ident`
LL | ($a:ident) => ();
| ^^^^^^^^
error: no rules expected the token `e`
error: no rules expected `e`
--> $DIR/missing-comma.rs:23:21
|
LL | macro_rules! foo {
@ -38,7 +38,7 @@ note: while trying to match meta-variable `$d:ident`
LL | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
| ^^^^^^^^
error: no rules expected the token `d`
error: no rules expected `d`
--> $DIR/missing-comma.rs:25:18
|
LL | macro_rules! foo {
@ -55,7 +55,7 @@ note: while trying to match meta-variable `$c:ident`
LL | ($a:ident, $b:ident, $c:ident) => ();
| ^^^^^^^^
error: no rules expected the token `d`
error: no rules expected `d`
--> $DIR/missing-comma.rs:27:18
|
LL | macro_rules! foo {
@ -85,7 +85,7 @@ note: while trying to match meta-variable `$arg:tt`
LL | ($lvl:expr, $($arg:tt)+) => {}
| ^^^^^^^
error: no rules expected the token `,`
error: no rules expected `,`
--> $DIR/missing-comma.rs:32:38
|
LL | macro_rules! check {

View File

@ -16,7 +16,7 @@ macro complex_nonterminal($nt_item: item) {
struct S;
}
n!(a $nt_item b); //~ ERROR no rules expected the token `enum E {}`
n!(a $nt_item b); //~ ERROR no rules expected item `enum E {}`
}
simple_nonterminal!(a, 'a, (x, y, z)); // OK
@ -29,10 +29,10 @@ macro_rules! foo {
(ident $x:ident) => { bar!(ident $x); };
(lifetime $x:lifetime) => { bar!(lifetime $x); };
(tt $x:tt) => { bar!(tt $x); };
(expr $x:expr) => { bar!(expr $x); }; //~ ERROR: no rules expected the token `3`
(literal $x:literal) => { bar!(literal $x); }; //~ ERROR: no rules expected the token `4`
(path $x:path) => { bar!(path $x); }; //~ ERROR: no rules expected the token `a::b::c`
(stmt $x:stmt) => { bar!(stmt $x); }; //~ ERROR: no rules expected the token `let abc = 0`
(expr $x:expr) => { bar!(expr $x); }; //~ ERROR: no rules expected expression `3`
(literal $x:literal) => { bar!(literal $x); }; //~ ERROR: no rules expected literal `4`
(path $x:path) => { bar!(path $x); }; //~ ERROR: no rules expected path `a::b::c`
(stmt $x:stmt) => { bar!(stmt $x); }; //~ ERROR: no rules expected statement `let abc = 0`
}
macro_rules! bar {

View File

@ -1,4 +1,4 @@
error: no rules expected the token `enum E {}`
error: no rules expected item `enum E {}`
--> $DIR/nonterminal-matching.rs:19:10
|
LL | macro n(a $nt_item b) {
@ -10,7 +10,7 @@ LL | n!(a $nt_item b);
LL | complex_nonterminal!(enum E {});
| ------------------------------- in this macro invocation
|
note: while trying to match `enum E {}`
note: while trying to match item `enum E {}`
--> $DIR/nonterminal-matching.rs:15:15
|
LL | macro n(a $nt_item b) {
@ -23,7 +23,7 @@ LL | complex_nonterminal!(enum E {});
= help: try using `:tt` instead in the macro definition
= note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `3`
error: no rules expected expression `3`
--> $DIR/nonterminal-matching.rs:32:35
|
LL | (expr $x:expr) => { bar!(expr $x); };
@ -45,7 +45,7 @@ LL | (expr 3) => {};
= help: try using `:tt` instead in the macro definition
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `4`
error: no rules expected literal `4`
--> $DIR/nonterminal-matching.rs:33:44
|
LL | (literal $x:literal) => { bar!(literal $x); };
@ -67,7 +67,7 @@ LL | (literal 4) => {};
= help: try using `:tt` instead in the macro definition
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `a::b::c`
error: no rules expected path `a::b::c`
--> $DIR/nonterminal-matching.rs:34:35
|
LL | (path $x:path) => { bar!(path $x); };
@ -89,7 +89,7 @@ LL | (path a::b::c) => {};
= help: try using `:tt` instead in the macro definition
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `let abc = 0`
error: no rules expected statement `let abc = 0`
--> $DIR/nonterminal-matching.rs:35:35
|
LL | (stmt $x:stmt) => { bar!(stmt $x); };
@ -101,7 +101,7 @@ LL | macro_rules! bar {
LL | foo!(stmt let abc = 0);
| ---------------------- in this macro invocation
|
note: while trying to match `let`
note: while trying to match keyword `let`
--> $DIR/nonterminal-matching.rs:45:11
|
LL | (stmt let abc = 0) => {};

View File

@ -1,4 +1,4 @@
error: no rules expected the token `bcd`
error: no rules expected `bcd`
--> $DIR/trace_faulty_macros.rs:7:26
|
LL | macro_rules! my_faulty_macro {

View File

@ -3,7 +3,7 @@ use std::mem::offset_of;
fn main() {
offset_of!(NotEnoughArguments); //~ ERROR unexpected end of macro invocation
offset_of!(NotEnoughArgumentsWithAComma, ); //~ ERROR unexpected end of macro invocation
offset_of!(Container, field, too many arguments); //~ ERROR no rules expected the token `too`
offset_of!(Container, field, too many arguments); //~ ERROR no rules expected `too`
offset_of!(S, f); // compiles fine
offset_of!(S, f,); // also compiles fine
offset_of!(S, f.); //~ ERROR unexpected token: `)`

View File

@ -16,7 +16,7 @@ LL | offset_of!(NotEnoughArgumentsWithAComma, );
note: while trying to match meta-variable `$fields:expr`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
error: no rules expected the token `too`
error: no rules expected `too`
--> $DIR/offset-of-arg-count.rs:6:34
|
LL | offset_of!(Container, field, too many arguments);

View File

@ -76,7 +76,7 @@ error: suffixes on a tuple index are invalid
LL | offset_of!((u8, u8), 1_u8);
| ^^^^ invalid suffix `u8`
error: no rules expected the token `+`
error: no rules expected `+`
--> $DIR/offset-of-tuple.rs:11:26
|
LL | offset_of!((u8, u8), +1);

View File

@ -9,5 +9,5 @@ macro_rules! accept_pat {
($p:pat) => {};
}
accept_pat!(p | q); //~ ERROR no rules expected the token `|`
accept_pat!(|p| q); //~ ERROR no rules expected the token `|`
accept_pat!(p | q); //~ ERROR no rules expected `|`
accept_pat!(|p| q); //~ ERROR no rules expected `|`

View File

@ -1,4 +1,4 @@
error: no rules expected the token `|`
error: no rules expected `|`
--> $DIR/or-patterns-syntactic-fail-2018.rs:12:15
|
LL | macro_rules! accept_pat {
@ -13,7 +13,7 @@ note: while trying to match meta-variable `$p:pat`
LL | ($p:pat) => {};
| ^^^^^^
error: no rules expected the token `|`
error: no rules expected `|`
--> $DIR/or-patterns-syntactic-fail-2018.rs:13:13
|
LL | macro_rules! accept_pat {

View File

@ -4,6 +4,6 @@ macro_rules! outer {
outer! {
//! Inner
} //~^ ERROR no rules expected the token `!`
} //~^ ERROR no rules expected `!`
fn main() { }

View File

@ -1,4 +1,4 @@
error: no rules expected the token `!`
error: no rules expected `!`
--> $DIR/macro-doc-comments-1.rs:6:5
|
LL | macro_rules! outer {

View File

@ -4,6 +4,6 @@ macro_rules! inner {
inner! {
/// Outer
} //~^ ERROR no rules expected the token `[`
} //~^ ERROR no rules expected `[`
fn main() { }

View File

@ -1,4 +1,4 @@
error: no rules expected the token `[`
error: no rules expected `[`
--> $DIR/macro-doc-comments-2.rs:6:5
|
LL | macro_rules! inner {

View File

@ -68,7 +68,7 @@ fn _macros() {
_ => {}
}
use_expr!(let 0 = 1);
//~^ ERROR no rules expected the token `let`
//~^ ERROR no rules expected keyword `let`
}
fn main() {}

View File

@ -131,7 +131,7 @@ LL | use_expr!((let 0 = 1));
|
= note: only supported directly in conditions of `if` and `while` expressions
error: no rules expected the token `let`
error: no rules expected keyword `let`
--> $DIR/feature-gate.rs:70:15
|
LL | macro_rules! use_expr {

View File

@ -54,7 +54,7 @@ fn _macros() {
#[cfg(FALSE)] (let 0 = 1);
//~^ ERROR expected expression, found `let` statement
use_expr!(let 0 = 1);
//~^ ERROR no rules expected the token `let`
//~^ ERROR no rules expected keyword `let`
}
fn main() {}

View File

@ -14,7 +14,7 @@ LL | noop_expr!((let 0 = 1));
|
= note: only supported directly in conditions of `if` and `while` expressions
error: no rules expected the token `let`
error: no rules expected keyword `let`
--> $DIR/feature-gate.rs:56:15
|
LL | macro_rules! use_expr {

View File

@ -5,5 +5,5 @@ macro_rules! identity {
}
fn main() {
let identity!(_) = 10; //~ ERROR no rules expected the token `_`
let identity!(_) = 10; //~ ERROR no rules expected reserved identifier `_`
}

View File

@ -1,4 +1,4 @@
error: no rules expected the token `_`
error: no rules expected reserved identifier `_`
--> $DIR/underscore-ident-matcher.rs:8:19
|
LL | macro_rules! identity {