about summary refs log tree commit diff
path: root/src/test/codegen/try_identity.rs
blob: 81e2435e5b80e4232b8fa49e569d9960389468b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts

// Ensure that `x?` has no overhead on `Result<T, E>` due to identity `match`es in lowering.
// This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`.

#![crate_type = "lib"]

type R = Result<u64, i32>;

#[no_mangle]
fn try_identity(x: R) -> R {
// CHECK: start:
// CHECK-NOT: br {{.*}}
// CHECK ret void
    let y = x?;
    Ok(y)
}