summaryrefslogtreecommitdiffstats
path: root/tests/incremental/hygiene/auxiliary/cached_hygiene.rs
blob: b31f60e972bf0bd2fefc74e8051919cacaac1972 (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
// revisions:rpass1 rpass2
// compile-flags: -Z query-dep-graph

// We use #[inline(always)] to ensure that the downstream crate
// will always load the MIR for these functions

#![feature(rustc_attrs)]

#[allow(unused)]
macro_rules! first_macro {
    () => {
        println!("New call!");
    }
}

#[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir,promoted_mir", cfg="rpass2")]
#[inline(always)]
pub fn changed_fn() {
    // This will cause additional hygiene to be generate,
    // which will cause the SyntaxContext/ExpnId raw ids to be
    // different when we write out `my_fn` to the crate metadata.
    #[cfg(rpass2)]
    first_macro!();
}

macro_rules! print_loc {
    () => {
        println!("Caller loc: {}", std::panic::Location::caller());
    }
}

#[rustc_clean(cfg="rpass2")]
#[inline(always)]
pub fn unchanged_fn() {
    print_loc!();
}