]> git.proxmox.com Git - rustc.git/blame - src/test/codegen/slice-iter-len-eq-zero.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / codegen / slice-iter-len-eq-zero.rs
CommitLineData
dc9dc135
XL
1// no-system-llvm
2// compile-flags: -O
2b03887a 3// ignore-debug: the debug assertions add extra comparisons
dc9dc135
XL
4#![crate_type = "lib"]
5
6type Demo = [u8; 3];
7
8// CHECK-LABEL: @slice_iter_len_eq_zero
9#[no_mangle]
10pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool {
11 // CHECK-NOT: sub
923072b8 12 // CHECK: %2 = icmp eq {{i8\*|ptr}} %1, %0
dc9dc135
XL
13 // CHECK: ret i1 %2
14 y.len() == 0
15}
2b03887a
FG
16
17// CHECK-LABEL: @array_into_iter_len_eq_zero
18#[no_mangle]
19pub fn array_into_iter_len_eq_zero(y: std::array::IntoIter<Demo, 123>) -> bool {
20 // This should be able to just check that the indexes are equal, and not
21 // need any subtractions or comparisons to handle `start > end`.
22
23 // CHECK-NOT: icmp
24 // CHECK-NOT: sub
25 // CHECK: %1 = icmp eq {{i16|i32|i64}}
26 // CHECK: ret i1 %1
27 y.len() == 0
28}