about summary refs log tree commit diff
path: root/tests/mir-opt/building/dump_mir_cycle.rs
blob: ab0f2ea6db8634f1baa1ebd16adff07971250e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ compile-flags: -Zmir-opt-level=0

#[derive(Debug)]
pub struct Thing {
    pub next: &'static Thing,
}

pub static THING: Thing = Thing { next: &THING };
// CHECK: alloc{{.+}} (static: THING)

const fn thing() -> &'static Thing {
    &MUTUALLY_RECURSIVE
}

pub static MUTUALLY_RECURSIVE: Thing = Thing { next: thing() };
// CHECK: alloc{{.+}} (static: MUTUALLY_RECURSIVE)

fn main() {
    // Generate optimized MIR for the const fn, too.
    thing();
}