This optimization depends on inlining for the identity conversions introduced by the lowering of the `?`. To take advantage of `SimplifyArmIdentity`, `-Z mir-opt-level=2` is required because that triggers the inlining MIR optimization.
17 lines
423 B
Rust
17 lines
423 B
Rust
// compile-flags: -C no-prepopulate-passes -Z mir-opt-level=2
|
|
|
|
// Ensure that `x?` has no overhead on `Result<T, E>` due to identity `match`es in lowering.
|
|
// This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`.
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
type R = Result<u64, i32>;
|
|
|
|
#[no_mangle]
|
|
fn try_identity(x: R) -> R {
|
|
// CHECK: start:
|
|
// CHECK-NOT: br {{.*}}
|
|
// CHECK ret void
|
|
let y = x?;
|
|
Ok(y)
|
|
}
|