1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Tests that `?` is a Kleene op and not a macro separator in the 2018 edition.
13 // compile-flags: --edition=2018
15 #![feature(macro_at_most_once_rep)]
22 ($(a),?) => {} //~ERROR the `?` macro repetition operator
25 macro_rules! barplus {
26 ($(a)?+) => {} // ok. matches "a+" and "+"
29 macro_rules! barstar {
30 ($(a)?*) => {} // ok. matches "a*" and "*"
36 foo!(a?); //~ ERROR no rules expected the token `?`
37 foo!(a?a); //~ ERROR no rules expected the token `?`
38 foo!(a?a?a); //~ ERROR no rules expected the token `?`
40 barplus!(); //~ERROR unexpected end of macro invocation
41 barplus!(a); //~ERROR unexpected end of macro invocation
42 barplus!(a?); //~ ERROR no rules expected the token `?`
43 barplus!(a?a); //~ ERROR no rules expected the token `?`
47 barstar!(); //~ERROR unexpected end of macro invocation
48 barstar!(a); //~ERROR unexpected end of macro invocation
49 barstar!(a?); //~ ERROR no rules expected the token `?`
50 barstar!(a?a); //~ ERROR no rules expected the token `?`