summaryrefslogtreecommitdiffstats
path: root/tests/codegen/slice-iter-fold.rs
blob: a55425cb6bbc6bb0d8ce88f94e4608f8b4c8029d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// ignore-debug: the debug assertions get in the way
// compile-flags: -O
#![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))
}