diff options
Diffstat (limited to 'tests/mir-opt/pre-codegen/option_bubble_debug.rs')
| -rw-r--r-- | tests/mir-opt/pre-codegen/option_bubble_debug.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/mir-opt/pre-codegen/option_bubble_debug.rs b/tests/mir-opt/pre-codegen/option_bubble_debug.rs new file mode 100644 index 00000000000..b9bf78a1d6e --- /dev/null +++ b/tests/mir-opt/pre-codegen/option_bubble_debug.rs @@ -0,0 +1,29 @@ +//@ compile-flags: -Copt-level=0 -Zmir-opt-level=1 -Cdebuginfo=limited +//@ edition: 2024 +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + +#![crate_type = "lib"] +#![feature(try_blocks)] + +// EMIT_MIR option_bubble_debug.option_direct.PreCodegen.after.mir +pub fn option_direct(x: Option<u32>) -> Option<u32> { + // CHECK-LABEL: fn option_direct(_1: Option<u32>) -> Option<u32> + // CHECK: = discriminant(_1); + // CHECK: [[TEMP:_.+]] = Not({{.+}}); + // CHECK: _0 = Option::<u32>::Some(move [[TEMP]]); + + match x { + Some(x) => Some(!x), + None => None, + } +} + +// EMIT_MIR option_bubble_debug.option_traits.PreCodegen.after.mir +pub fn option_traits(x: Option<u32>) -> Option<u32> { + // CHECK-LABEL: fn option_traits(_1: Option<u32>) -> Option<u32> + // CHECK: = <Option<u32> as Try>::branch(copy _1) + // CHECK: [[TEMP:_.+]] = Not({{.+}}); + // CHECK: _0 = <Option<u32> as Try>::from_output(move [[TEMP]]) + + try { !(x?) } +} |
