1 // compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts
2 // EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff
3 // EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff
4 // EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff
5 // EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff
6 // EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff
7 // EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff
9 fn id(o: Option<u8>) -> Option<u8> {
16 fn id_result(r: Result<u8, i32>) -> Result<u8, i32> {
23 fn into_result<T, E>(r: Result<T, E>) -> Result<T, E> {
27 fn from_error<T, E>(e: E) -> Result<T, E> {
31 // This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure,
32 // so the relevant desugar is copied inline in order to keep the test testing the same thing.
33 // FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR
34 // optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not.
35 fn id_try(r: Result<u8, i32>) -> Result<u8, i32> {
36 let x = match into_result(r) {
37 Err(e) => return from_error(From::from(e)),