]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-at-most-once-rep-2015.rs
Auto merge of #83152 - guswynn:jemallocator_part2, r=Mark-Simulacrum
[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 // The Kleene op `?` does not admit a separator before it.
10 macro_rules! baz {
11     ($(a),?) => {}; //~ERROR the `?` macro repetition operator
12 }
13
14 macro_rules! barplus {
15     ($(a)?+) => {}; // ok. matches "a+" and "+"
16 }
17
18 macro_rules! barstar {
19     ($(a)?*) => {}; // ok. matches "a*" and "*"
20 }
21
22 pub fn main() {
23     foo!();
24     foo!(a);
25     foo!(a?); //~ ERROR no rules expected the token `?`
26     foo!(a?a); //~ ERROR no rules expected the token `?`
27     foo!(a?a?a); //~ ERROR no rules expected the token `?`
28
29     barplus!(); //~ERROR unexpected end of macro invocation
30     barplus!(a); //~ERROR unexpected end of macro invocation
31     barplus!(a?); //~ ERROR no rules expected the token `?`
32     barplus!(a?a); //~ ERROR no rules expected the token `?`
33     barplus!(a+);
34     barplus!(+);
35
36     barstar!(); //~ERROR unexpected end of macro invocation
37     barstar!(a); //~ERROR unexpected end of macro invocation
38     barstar!(a?); //~ ERROR no rules expected the token `?`
39     barstar!(a?a); //~ ERROR no rules expected the token `?`
40     barstar!(a*);
41     barstar!(*);
42 }