diff options
| author | Lzu Tao <taolzu@gmail.com> | 2024-05-20 21:33:53 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2024-06-09 07:35:24 +0000 |
| commit | 5f527eb562ff670cf9545817575ff6a7f6088bc7 (patch) | |
| tree | 7f40051e377683ee3a24a855b10e0c2b6a1adbb7 /tests/codegen/issues/issue-68667-unwrap-combinators.rs | |
| parent | bf178187c7d7f671d233b012e6ebcd53e3d60a62 (diff) | |
| download | rust-5f527eb562ff670cf9545817575ff6a7f6088bc7.tar.gz rust-5f527eb562ff670cf9545817575ff6a7f6088bc7.zip | |
add codegen test for #68667
Diffstat (limited to 'tests/codegen/issues/issue-68667-unwrap-combinators.rs')
| -rw-r--r-- | tests/codegen/issues/issue-68667-unwrap-combinators.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/codegen/issues/issue-68667-unwrap-combinators.rs b/tests/codegen/issues/issue-68667-unwrap-combinators.rs new file mode 100644 index 00000000000..05760dc9b55 --- /dev/null +++ b/tests/codegen/issues/issue-68667-unwrap-combinators.rs @@ -0,0 +1,17 @@ +#![crate_type = "lib"] + +//@ compile-flags: -O + +// MIR inlining now optimizes this code. + +// CHECK-LABEL: @unwrap_combinators +// CHECK: icmp +// CHECK-NEXT: icmp +// CHECK-NEXT: select i1 +// CHECK-NEXT: ret i1 +#[no_mangle] +pub fn unwrap_combinators(a: Option<i32>, b: i32) -> bool { + a.map(|t| t >= b) + .unwrap_or(false) +} + |
