1 // compile-flags: -Zunsound-mir-opts
2 // EMIT_MIR simplify_try.try_identity.SimplifyArmIdentity.diff
3 // EMIT_MIR simplify_try.try_identity.SimplifyBranchSame.after.mir
4 // EMIT_MIR simplify_try.try_identity.SimplifyLocals.after.mir
5 // EMIT_MIR simplify_try.try_identity.DestinationPropagation.diff
8 fn into_result<T, E>(r: Result<T, E>) -> Result<T, E> {
12 fn from_error<T, E>(e: E) -> Result<T, E> {
16 // This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure,
17 // so the relevant desugar is copied inline in order to keep the test testing the same thing.
18 // FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR
19 // optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not.
20 fn try_identity(x: Result<u32, i32>) -> Result<u32, i32> {
21 let y = match into_result(x) {
22 Err(e) => return from_error(From::from(e)),
29 let _ = try_identity(Ok(0));