]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.rs
Rollup merge of #53407 - pnkfelix:partial-53351-make-more-ported-compile-fail-tests...
[rust.git] / src / test / ui / macros / macro-at-most-once-rep-2018-feature-gate.rs
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.
4 //
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.
10
11 // Feature gate test for macro_at_most_once_rep under 2018 edition.
12
13 // gate-test-macro_at_most_once_rep
14 // compile-flags: --edition=2018
15
16 macro_rules! foo {
17     ($(a)?) => {}
18     //~^ERROR using the `?` macro Kleene operator for
19     //~|ERROR expected `*` or `+`
20 }
21
22 macro_rules! baz {
23     ($(a),?) => {} //~ERROR expected `*` or `+`
24 }
25
26 macro_rules! barplus {
27     ($(a)?+) => {}
28     //~^ERROR using the `?` macro Kleene operator for
29     //~|ERROR expected `*` or `+`
30 }
31
32 macro_rules! barstar {
33     ($(a)?*) => {}
34     //~^ERROR using the `?` macro Kleene operator for
35     //~|ERROR expected `*` or `+`
36 }
37
38 pub fn main() {
39     foo!();
40     foo!(a);
41     foo!(a?); //~ ERROR no rules expected the token `?`
42     foo!(a?a); //~ ERROR no rules expected the token `?`
43     foo!(a?a?a); //~ ERROR no rules expected the token `?`
44 }
45