Debian Codegraph @

gcc/testsuite/rust/compile/macros/mbe/macro54.rs

raw
1 #[lang = "sized"]
2 pub trait Sized {}
3
4 macro_rules! foo {
5 () => {"foo"};
6 (number) => { 12 };
7 (false) => { false };
8 }
9
10 pub const A: &'static str = foo!();
11 pub static B: &'static str = foo!();
12
13 pub trait Number {
14 const VALUE: u32;
15 }
16
17 impl Number for u32 {
18 const VALUE: u32 = foo!(number);
19 }
20
21 impl u32 {
22 pub const TWELVE: u32 = foo!(number);
23 }
24
25 pub enum E {
26 Variant = foo!(number),
27 }
28
29 pub fn f(c: bool) -> &'static str {
30 match c {
31 false => foo!(),
32 true if foo!(false) => "abc",
33 _ => "xyz"
34 }
35 }
36
37
38 fn main() {
39 let _ = A;
40 let _ = u32::VALUE - u32::TWELVE;
41 }