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