]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-of-higher-order.rs
Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors
[rust.git] / tests / ui / macros / macro-of-higher-order.rs
1 // run-pass
2
3 macro_rules! higher_order {
4     (subst $lhs:tt => $rhs:tt) => ({
5             macro_rules! anon { $lhs => $rhs }
6             anon!(1_usize, 2_usize, "foo")
7     });
8 }
9
10 macro_rules! outer {
11     ($x:expr; $fragment:ident) => {
12         macro_rules! inner { ($y:$fragment) => { $x + $y } }
13     }
14 }
15
16 fn main() {
17     let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo)));
18     assert_eq!(val, (3, "foo"));
19
20     outer!(2; expr);
21     assert_eq!(inner!(3), 5);
22 }