about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorThe 8472 <git@infinite-source.de>2023-07-29 16:25:53 +0200
committerThe 8472 <git@infinite-source.de>2024-01-07 03:44:04 +0100
commit93b34a5ffa753d6cdaca8aab349408e945412ebd (patch)
tree6b80777523201621c81f52390b5edadda2770af7 /tests/codegen
parentfd8ba7bc3cfcc72f79da33f74b19c905f0cbb835 (diff)
downloadrust-93b34a5ffa753d6cdaca8aab349408e945412ebd.tar.gz
rust-93b34a5ffa753d6cdaca8aab349408e945412ebd.zip
mark vec::IntoIter pointers as `!nonnull`
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/vec-iter.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/codegen/vec-iter.rs b/tests/codegen/vec-iter.rs
new file mode 100644
index 00000000000..0282791e9d1
--- /dev/null
+++ b/tests/codegen/vec-iter.rs
@@ -0,0 +1,46 @@
+// ignore-debug: the debug assertions get in the way
+// compile-flags: -O
+#![crate_type = "lib"]
+#![feature(exact_size_is_empty)]
+
+use std::vec;
+
+// CHECK-LABEL: @vec_iter_len_nonnull
+#[no_mangle]
+pub fn vec_iter_len_nonnull(it: &vec::IntoIter<u8>) -> usize {
+    // CHECK: load ptr
+    // CHECK-SAME: !nonnull
+    // CHECK-SAME: !noundef
+    // CHECK: load ptr
+    // CHECK-SAME: !nonnull
+    // CHECK-SAME: !noundef
+    // CHECK: sub nuw
+    // CHECK: ret
+    it.len()
+}
+
+// CHECK-LABEL: @vec_iter_is_empty_nonnull
+#[no_mangle]
+pub fn vec_iter_is_empty_nonnull(it: &vec::IntoIter<u8>) -> bool {
+    // CHECK: load ptr
+    // CHECK-SAME: !nonnull
+    // CHECK-SAME: !noundef
+    // CHECK: load ptr
+    // CHECK-SAME: !nonnull
+    // CHECK-SAME: !noundef
+    // CHECK: ret
+    it.is_empty()
+}
+
+// CHECK-LABEL: @vec_iter_next
+#[no_mangle]
+pub fn vec_iter_next(it: &mut vec::IntoIter<u8>) -> Option<u8> {
+    // CHECK: load ptr
+    // CHECK-SAME: !nonnull
+    // CHECK-SAME: !noundef
+    // CHECK: load ptr
+    // CHECK-SAME: !nonnull
+    // CHECK-SAME: !noundef
+    // CHECK: ret
+    it.next()
+}