2019-05-22 03:58:29 +00:00
|
|
|
// Tests that `?` is a Kleene op and not a macro separator in the 2018 edition.
|
2018-06-16 02:49:00 +00:00
|
|
|
|
2018-08-16 07:36:11 +00:00
|
|
|
// edition:2018
|
2018-06-16 02:49:00 +00:00
|
|
|
|
|
|
|
macro_rules! foo {
|
2018-11-24 22:27:13 +00:00
|
|
|
($(a)?) => {};
|
2018-06-16 02:49:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-22 03:52:47 +00:00
|
|
|
// The Kleene op `?` does not admit a separator before it.
|
2018-06-16 02:49:00 +00:00
|
|
|
macro_rules! baz {
|
2018-11-24 22:27:13 +00:00
|
|
|
($(a),?) => {}; //~ERROR the `?` macro repetition operator
|
2018-06-16 02:49:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! barplus {
|
2018-11-24 22:27:13 +00:00
|
|
|
($(a)?+) => {}; // ok. matches "a+" and "+"
|
2018-06-16 02:49:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! barstar {
|
2018-11-24 22:27:13 +00:00
|
|
|
($(a)?*) => {}; // ok. matches "a*" and "*"
|
2018-06-16 02:49:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 `?`
|
|
|
|
|
|
|
|
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 `?`
|
2018-11-25 00:40:03 +00:00
|
|
|
barplus!(a+);
|
2018-06-16 02:49:00 +00:00
|
|
|
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*);
|
|
|
|
barstar!(*);
|
|
|
|
}
|