1 // compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts
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`.
8 type R = Result<u64, i32>;
10 // This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure,
11 // so the relevant desugar is copied inline in order to keep the test testing the same thing.
12 // FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR
13 // optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not.
15 pub fn try_identity(x: R) -> R {
17 // FIXME(JakobDegen): Broken by deaggregation change CHECK-NOT\: br {{.*}}
19 let y = match into_result(x) {
20 Err(e) => return from_error(From::from(e)),
27 fn into_result<T, E>(r: Result<T, E>) -> Result<T, E> {
32 fn from_error<T, E>(e: E) -> Result<T, E> {