Fix typo in error message + update tests

This commit is contained in:
Mark Mansi 2018-01-25 15:23:43 -06:00
parent f59b821944
commit 51ef7393ef
4 changed files with 20 additions and 4 deletions

View file

@ -432,6 +432,6 @@ where
};
sess.span_diagnostic
.span_err(span, "expected one of: `*`, `+`, or `?`");
.span_err(span, "expected one of: `*`, `+`, or `?`");
(None, KleeneOp::ZeroOrMore)
}

View file

@ -11,7 +11,7 @@
#![allow(unused_macros)]
macro_rules! assign {
(($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected `*` or `+`
(($($a:tt)*) = ($($b:tt))*) => { //~ ERROR 14:22: 14:29: expected one of: `*`, `+`, or `?`
$($a)* = $($b)*
}
}

View file

@ -12,6 +12,10 @@ macro_rules! foo {
($(a)?) => {}
}
macro_rules! baz {
($(a),?) => {} // comma separator is meaningless for `?`
}
macro_rules! bar {
($(a)?+) => {}
}
@ -20,7 +24,13 @@ pub fn main() {
foo!(a?a?a); //~ ERROR no rules expected the token `?`
foo!(a?a); //~ ERROR no rules expected the token `?`
foo!(a?); //~ ERROR no rules expected the token `?`
bar!(); //~ ERROR no rules expected the token `)`
baz!(a?a?a); //~ ERROR no rules expected the token `?`
baz!(a?a); //~ ERROR no rules expected the token `?`
baz!(a?); //~ ERROR no rules expected the token `?`
baz!(a,); //~ ERROR no rules expected the token `,`
baz!(a?a?a,); //~ ERROR no rules expected the token `?`
baz!(a?a,); //~ ERROR no rules expected the token `?`
baz!(a?,); //~ ERROR no rules expected the token `?`
bar!(); //~ ERROR unexpected end of macro invocation
bar!(a?); //~ ERROR no rules expected the token `?`
}

View file

@ -12,6 +12,10 @@ macro_rules! foo {
($(a)?) => {}
}
macro_rules! baz {
($(a),?) => {} // comma separator is meaningless for `?`
}
macro_rules! bar {
($(a)?+) => {}
}
@ -19,6 +23,8 @@ macro_rules! bar {
pub fn main() {
foo!();
foo!(a);
baz!();
baz!(a);
bar!(a);
bar!(a?a);
bar!(a?a?a);