about summary refs log tree commit diff
path: root/tests/codegen/slice-iter-fold.rs
diff options
context:
space:
mode:
authorThe 8472 <git@infinite-source.de>2023-06-12 14:05:46 +0200
committerThe 8472 <git@infinite-source.de>2023-06-12 23:47:08 +0200
commitba5b2f0b4b71662663a224f685b2b808d9c8f99a (patch)
tree388322d24bf561acd316cbd45d4b24cc4df69987 /tests/codegen/slice-iter-fold.rs
parentd89e4581594a5d96b9ddaa454de3b25d6cc34ee8 (diff)
downloadrust-ba5b2f0b4b71662663a224f685b2b808d9c8f99a.tar.gz
rust-ba5b2f0b4b71662663a224f685b2b808d9c8f99a.zip
add codegen test for slice::Iter::fold
Diffstat (limited to 'tests/codegen/slice-iter-fold.rs')
-rw-r--r--tests/codegen/slice-iter-fold.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/codegen/slice-iter-fold.rs b/tests/codegen/slice-iter-fold.rs
new file mode 100644
index 00000000000..9391c176130
--- /dev/null
+++ b/tests/codegen/slice-iter-fold.rs
@@ -0,0 +1,14 @@
+// ignore-debug: the debug assertions get in the way
+// compile-flags: -O
+// min-llvm-version: 16
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @slice_fold_to_last
+#[no_mangle]
+pub fn slice_fold_to_last(slice: &[i32]) -> Option<&i32> {
+    // CHECK-NOT: loop
+    // CHECK-NOT: br
+    // CHECK-NOT: call
+    // CHECK: ret
+    slice.iter().fold(None, |_, i| Some(i))
+}