]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-at-most-once-rep-2015.rs
Update tests since ? macro op is supported on 2015.
[rust.git] / src / test / ui / macros / macro-at-most-once-rep-2015.rs
1 // Tests that `?` is a Kleene op and not a macro separator in the 2015 edition.
2
3 // edition:2015
4
5 macro_rules! foo {
6     ($(a)?) => {};
7 }
8
9 macro_rules! baz {
10     ($(a),?) => {}; //~ERROR the `?` macro repetition operator
11 }
12
13 macro_rules! barplus {
14     ($(a)?+) => {}; // ok. matches "a+" and "+"
15 }
16
17 macro_rules! barstar {
18     ($(a)?*) => {}; // ok. matches "a*" and "*"
19 }
20
21 pub fn main() {
22     foo!();
23     foo!(a);
24     foo!(a?); //~ ERROR no rules expected the token `?`
25     foo!(a?a); //~ ERROR no rules expected the token `?`
26     foo!(a?a?a); //~ ERROR no rules expected the token `?`
27
28     barplus!(); //~ERROR unexpected end of macro invocation
29     barplus!(a); //~ERROR unexpected end of macro invocation
30     barplus!(a?); //~ ERROR no rules expected the token `?`
31     barplus!(a?a); //~ ERROR no rules expected the token `?`
32     barplus!(a+);
33     barplus!(+);
34
35     barstar!(); //~ERROR unexpected end of macro invocation
36     barstar!(a); //~ERROR unexpected end of macro invocation
37     barstar!(a?); //~ ERROR no rules expected the token `?`
38     barstar!(a?a); //~ ERROR no rules expected the token `?`
39     barstar!(a*);
40     barstar!(*);
41 }