2023-10-16 12:36:39 -05:00
|
|
|
// skip-filecheck
|
2024-02-22 06:10:29 -06:00
|
|
|
//@ compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
|
2023-04-23 04:38:37 -05:00
|
|
|
|
2022-08-20 23:47:53 -05:00
|
|
|
// Track the status of MIR optimizations simplifying `Ok(res?)` for both the old and new desugarings
|
|
|
|
// of that syntax.
|
|
|
|
|
|
|
|
use std::ops::ControlFlow;
|
|
|
|
|
2023-04-23 04:38:37 -05:00
|
|
|
// EMIT_MIR try_identity.new.PreCodegen.after.mir
|
2022-08-20 23:47:53 -05:00
|
|
|
fn new<T, E>(x: Result<T, E>) -> Result<T, E> {
|
|
|
|
Ok(
|
|
|
|
match {
|
|
|
|
match x {
|
|
|
|
Ok(v) => ControlFlow::Continue(v),
|
|
|
|
Err(e) => ControlFlow::Break(e),
|
|
|
|
}
|
|
|
|
} {
|
|
|
|
ControlFlow::Continue(v) => v,
|
|
|
|
ControlFlow::Break(e) => return Err(e),
|
2024-06-02 19:18:33 -05:00
|
|
|
},
|
2022-08-20 23:47:53 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-04-23 04:38:37 -05:00
|
|
|
// EMIT_MIR try_identity.old.PreCodegen.after.mir
|
2022-08-20 23:47:53 -05:00
|
|
|
fn old<T, E>(x: Result<T, E>) -> Result<T, E> {
|
2024-06-02 19:18:33 -05:00
|
|
|
Ok(match x {
|
|
|
|
Ok(v) => v,
|
|
|
|
Err(e) => return Err(e),
|
|
|
|
})
|
2022-08-20 23:47:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = new::<(), ()>(Ok(()));
|
|
|
|
let _ = old::<(), ()>(Ok(()));
|
|
|
|
}
|