]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/issue-37945.rs
Rollup merge of #95749 - compiler-errors:ambig, r=oli-obk
[rust.git] / src / test / codegen / issue-37945.rs
1 // compile-flags: -O -Zmerge-functions=disabled
2 // ignore-x86
3 // ignore-arm
4 // ignore-emscripten
5 // ignore-gnux32
6 // ignore 32-bit platforms (LLVM has a bug with them)
7
8 // Check that LLVM understands that `Iter` pointer is not null. Issue #37945.
9
10 #![crate_type = "lib"]
11
12 use std::slice::Iter;
13
14 #[no_mangle]
15 pub fn is_empty_1(xs: Iter<f32>) -> bool {
16 // CHECK-LABEL: @is_empty_1(
17 // CHECK-NEXT:  start:
18 // CHECK-NEXT:    [[A:%.*]] = icmp ne i32* %xs.1, null
19 // CHECK-NEXT:    tail call void @llvm.assume(i1 [[A]])
20 // CHECK-NEXT:    [[B:%.*]] = icmp eq i32* %xs.0, %xs.1
21 // CHECK-NEXT:    ret i1 [[B:%.*]]
22     {xs}.next().is_none()
23 }
24
25 #[no_mangle]
26 pub fn is_empty_2(xs: Iter<f32>) -> bool {
27 // CHECK-LABEL: @is_empty_2
28 // CHECK-NEXT:  start:
29 // CHECK-NEXT:    [[C:%.*]] = icmp ne i32* %xs.1, null
30 // CHECK-NEXT:    tail call void @llvm.assume(i1 [[C]])
31 // CHECK-NEXT:    [[D:%.*]] = icmp eq i32* %xs.0, %xs.1
32 // CHECK-NEXT:    ret i1 [[D:%.*]]
33     xs.map(|&x| x).next().is_none()
34 }