Skip to content

Commit ba5b2f0

Browse files
committed
add codegen test for slice::Iter::fold
1 parent d89e458 commit ba5b2f0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/codegen/slice-iter-fold.rs

+14
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)