]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/issue-41803.rs
Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors
[rust.git] / tests / ui / macros / issue-41803.rs
1 // run-pass
2 #![allow(unused_macro_rules)]
3
4 /// A compile-time map from identifiers to arbitrary (heterogeneous) expressions
5 macro_rules! ident_map {
6     ( $name:ident = { $($key:ident => $e:expr,)* } ) => {
7         macro_rules! $name {
8             $(
9                 ( $key ) => { $e };
10             )*
11             // Empty invocation expands to nothing. Needed when the map is empty.
12             () => {};
13         }
14     };
15 }
16
17 ident_map!(my_map = {
18     main => 0,
19 });
20
21 fn main() {
22     my_map!(main);
23 }