]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-tt-followed-by-seq.rs
Rollup merge of #92191 - jackh726:issue-89352, r=nikomatsakis
[rust.git] / src / test / 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 enum Join<A,B> {
9   Keep(A,B),
10   Skip(A,B),
11 }
12
13 macro_rules! parse_list {
14   ( < $a:expr; > $($b:tt)* ) => { Keep(parse_item!($a),parse_list!($($b)*)) };
15   ( $a:tt $($b:tt)* ) => { Skip(parse_item!($a), parse_list!($($b)*)) };
16   ( ) => { () };
17 }
18
19 macro_rules! parse_item {
20   ( $x:expr ) => { $x }
21 }
22
23 fn main() {
24     let list = parse_list!(<1;> 2 <3;> 4);
25     assert_eq!("Keep(1, Skip(2, Keep(3, Skip(4, ()))))",
26                format!("{:?}", list));
27 }