]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/inline/inline_diverging.rs
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
[rust.git] / tests / mir-opt / inline / inline_diverging.rs
1 // Tests inlining of diverging calls.
2 //
3 // ignore-wasm32-bare compiled with panic=abort by default
4 #![crate_type = "lib"]
5
6 // EMIT_MIR inline_diverging.f.Inline.diff
7 pub fn f() {
8     sleep();
9 }
10
11 // EMIT_MIR inline_diverging.g.Inline.diff
12 pub fn g(i: i32) -> u32 {
13     if i > 0 {
14         i as u32
15     } else {
16         panic();
17     }
18 }
19
20 // EMIT_MIR inline_diverging.h.Inline.diff
21 pub fn h() {
22     call_twice(sleep);
23 }
24
25 #[inline(always)]
26 pub fn call_twice<R, F: Fn() -> R>(f: F) -> (R, R) {
27     let a = f();
28     let b = f();
29     (a, b)
30 }
31
32 #[inline(always)]
33 fn panic() -> ! {
34     panic!();
35 }
36
37 #[inline(always)]
38 fn sleep() -> ! {
39     loop {}
40 }