summaryrefslogtreecommitdiffstats
path: root/tests/ui/macros/issue-41803.rs
blob: bccfdc611460ecdd6f3f4c8bdcbb2073872d7e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// run-pass
#![allow(unused_macro_rules)]

/// A compile-time map from identifiers to arbitrary (heterogeneous) expressions
macro_rules! ident_map {
    ( $name:ident = { $($key:ident => $e:expr,)* } ) => {
        macro_rules! $name {
            $(
                ( $key ) => { $e };
            )*
            // Empty invocation expands to nothing. Needed when the map is empty.
            () => {};
        }
    };
}

ident_map!(my_map = {
    main => 0,
});

fn main() {
    my_map!(main);
}