]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-5067.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-5067.rs
1 // Copyright 2016 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 #![allow(unused_macros)]
12
13 macro_rules! foo {
14 ( $()* ) => {};
15 //~^ ERROR repetition matches empty token tree
16 ( $()+ ) => {};
17 //~^ ERROR repetition matches empty token tree
18
19 ( $(),* ) => {}; // PASS
20 ( $(),+ ) => {}; // PASS
21
22 ( [$()*] ) => {};
23 //~^ ERROR repetition matches empty token tree
24 ( [$()+] ) => {};
25 //~^ ERROR repetition matches empty token tree
26
27 ( [$(),*] ) => {}; // PASS
28 ( [$(),+] ) => {}; // PASS
29
30 ( $($()* $(),* $(a)* $(a),* )* ) => {};
31 //~^ ERROR repetition matches empty token tree
32 ( $($()* $(),* $(a)* $(a),* )+ ) => {};
33 //~^ ERROR repetition matches empty token tree
34
35 ( $(a $(),* $(a)* $(a),* )* ) => {}; // PASS
36 ( $($(a)+ $(),* $(a)* $(a),* )+ ) => {}; // PASS
37
38 ( $(a $()+)* ) => {};
39 //~^ ERROR repetition matches empty token tree
40 ( $(a $()*)+ ) => {};
41 //~^ ERROR repetition matches empty token tree
42 }
43
44
45 // --- Original Issue --- //
46
47 macro_rules! make_vec {
48 (a $e1:expr $($(, a $e2:expr)*)*) => ([$e1 $($(, $e2)*)*]);
49 //~^ ERROR repetition matches empty token tree
50 }
51
52 fn main() {
53 let _ = make_vec![a 1, a 2, a 3];
54 }
55
56
57 // --- Minified Issue --- //
58
59 macro_rules! m {
60 ( $()* ) => {}
61 //~^ ERROR repetition matches empty token tree
62 }
63
64 m!();