diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
commit | 246f239d9f40f633160f0c18f87a20922d4e77bb (patch) | |
tree | 5a88572663584b3d4d28e5a20e10abab1be40884 /src/test/codegen/try_question_mark_nop.rs | |
parent | Releasing progress-linux version 1.64.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.tar.xz rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.zip |
Merging debian version 1.65.0+dfsg1-2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/codegen/try_question_mark_nop.rs')
-rw-r--r-- | src/test/codegen/try_question_mark_nop.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/codegen/try_question_mark_nop.rs b/src/test/codegen/try_question_mark_nop.rs new file mode 100644 index 000000000..d23938776 --- /dev/null +++ b/src/test/codegen/try_question_mark_nop.rs @@ -0,0 +1,54 @@ +// min-llvm-version: 15.0 +// compile-flags: -O -Z merge-functions=disabled --edition=2021 +// only-x86_64 + +#![crate_type = "lib"] +#![feature(try_blocks)] + +// These are now NOPs in LLVM 15, presumably thanks to nikic's change mentioned in +// <https://github.com/rust-lang/rust/issues/85133#issuecomment-1072168354>. +// Unfortunately, as of 2022-08-17 they're not yet nops for `u64`s nor `Option`. + +use std::ops::ControlFlow::{self, Continue, Break}; + +// CHECK-LABEL: @result_nop_match_32 +#[no_mangle] +pub fn result_nop_match_32(x: Result<i32, u32>) -> Result<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + match x { + Ok(x) => Ok(x), + Err(x) => Err(x), + } +} + +// CHECK-LABEL: @result_nop_traits_32 +#[no_mangle] +pub fn result_nop_traits_32(x: Result<i32, u32>) -> Result<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + try { + x? + } +} + +// CHECK-LABEL: @control_flow_nop_match_32 +#[no_mangle] +pub fn control_flow_nop_match_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + match x { + Continue(x) => Continue(x), + Break(x) => Break(x), + } +} + +// CHECK-LABEL: @control_flow_nop_traits_32 +#[no_mangle] +pub fn control_flow_nop_traits_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + try { + x? + } +} |