about summary refs log tree commit diff
path: root/tests/rustdoc-gui/src/macro_expansion/lib.rs
blob: 62a92d5d15eb96cbc9873f24094ef89e4fcc9e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Test crate used to check the `--generate-macro-expansion` option.
//@ compile-flags: -Zunstable-options --generate-macro-expansion --generate-link-to-definition

mod other;

#[macro_export]
macro_rules! bar {
    ($x:ident) => {{
        $x += 2;
        $x *= 2;
    }}
}

macro_rules! bar2 {
    () => {
        fn foo2() -> impl std::fmt::Display {
            String::new()
        }
    }
}

macro_rules! bar3 {
    () => {
        fn foo3() {}
        fn foo4() -> String { String::new() }
    }
}

bar2!();
bar3!();

#[derive(Debug, PartialEq)]
pub struct Bar;

#[derive(Debug
)]
pub struct Bar2;

fn y_f(_: &str, _: &str, _: &str) {}

fn foo() {
    let mut y = 0;
    bar!(y);
    println!("
    {y}
    ");
    // comment
    println!("
    {y}
    ");
    let s = y_f("\
bla", stringify!(foo), stringify!(bar));

    // Macro from another file.
    other_macro!(y);
}