]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/try_identity.rs
Suggest defining type parameter when appropriate
[rust.git] / src / test / codegen / try_identity.rs
1 // compile-flags: -C no-prepopulate-passes -Z mir-opt-level=2
2
3 // Ensure that `x?` has no overhead on `Result<T, E>` due to identity `match`es in lowering.
4 // This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`.
5
6 #![crate_type = "lib"]
7
8 type R = Result<u64, i32>;
9
10 #[no_mangle]
11 fn try_identity(x: R) -> R {
12 // CHECK: start:
13 // CHECK-NOT: br {{.*}}
14 // CHECK ret void
15     let y = x?;
16     Ok(y)
17 }