mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
dd2b027d5d
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.
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
// Tests that `?` is a Kleene op and not a macro separator in the 2018 edition.
|
|
|
|
//@ edition:2018
|
|
|
|
macro_rules! foo {
|
|
($(a)?) => {};
|
|
}
|
|
|
|
// The Kleene op `?` does not admit a separator before it.
|
|
macro_rules! baz {
|
|
($(a),?) => {}; //~ERROR the `?` macro repetition operator
|
|
}
|
|
|
|
macro_rules! barplus {
|
|
($(a)?+) => {}; // ok. matches "a+" and "+"
|
|
}
|
|
|
|
macro_rules! barstar {
|
|
($(a)?*) => {}; // ok. matches "a*" and "*"
|
|
}
|
|
|
|
pub fn main() {
|
|
foo!();
|
|
foo!(a);
|
|
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 `?`
|
|
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 `?`
|
|
barstar!(a?a); //~ ERROR no rules expected `?`
|
|
barstar!(a*);
|
|
barstar!(*);
|
|
}
|