We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d89e458 commit ba5b2f0Copy full SHA for ba5b2f0
tests/codegen/slice-iter-fold.rs
@@ -0,0 +1,14 @@
1
+// ignore-debug: the debug assertions get in the way
2
+// compile-flags: -O
3
+// min-llvm-version: 16
4
+#![crate_type = "lib"]
5
+
6
+// CHECK-LABEL: @slice_fold_to_last
7
+#[no_mangle]
8
+pub fn slice_fold_to_last(slice: &[i32]) -> Option<&i32> {
9
+ // CHECK-NOT: loop
10
+ // CHECK-NOT: br
11
+ // CHECK-NOT: call
12
+ // CHECK: ret
13
+ slice.iter().fold(None, |_, i| Some(i))
14
+}
0 commit comments