]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-tt-followed-by-seq.rs
Rollup merge of #106889 - scottmcm:windows-mut, r=cuviper
[rust.git] / tests / ui / macros / macro-tt-followed-by-seq.rs
1 // run-pass
2 // Regression test for issue #25436: permit token-trees to be followed
3 // by sequences, enabling more general parsing.
4
5 use self::Join::*;
6
7 #[derive(Debug)]
8 #[allow(unused_tuple_struct_fields)]
9 enum Join<A,B> {
10   Keep(A,B),
11   Skip(A,B),
12 }
13
14 macro_rules! parse_list {
15   ( < $a:expr; > $($b:tt)* ) => { Keep(parse_item!($a),parse_list!($($b)*)) };
16   ( $a:tt $($b:tt)* ) => { Skip(parse_item!($a), parse_list!($($b)*)) };
17   ( ) => { () };
18 }
19
20 macro_rules! parse_item {
21   ( $x:expr ) => { $x }
22 }
23
24 fn main() {
25     let list = parse_list!(<1;> 2 <3;> 4);
26     assert_eq!("Keep(1, Skip(2, Keep(3, Skip(4, ()))))",
27                format!("{:?}", list));
28 }