about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2022-10-27 13:40:45 +0100
committerclubby789 <jamie@hill-daniel.co.uk>2022-10-31 16:43:31 +0000
commit8e8fd02b272bf8ca8e4c8f4d20552ca26a468a80 (patch)
tree298bfd3b0f37878d9c51e472a042ba6f533d1f79 /src/test/codegen
parent2afca78a0b03db144c5d8b9f8868feebfe096309 (diff)
downloadrust-8e8fd02b272bf8ca8e4c8f4d20552ca26a468a80.tar.gz
rust-8e8fd02b272bf8ca8e4c8f4d20552ca26a468a80.zip
Specialize PartialEq for Option<num::NonZero*> and Option<ptr::NonNull>
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/option-nonzero-eq.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/codegen/option-nonzero-eq.rs b/src/test/codegen/option-nonzero-eq.rs
new file mode 100644
index 00000000000..598dcc19b49
--- /dev/null
+++ b/src/test/codegen/option-nonzero-eq.rs
@@ -0,0 +1,34 @@
+// compile-flags: -O -Zmerge-functions=disabled
+
+#![crate_type = "lib"]
+
+extern crate core;
+use core::num::{NonZeroU32, NonZeroI64};
+use core::ptr::NonNull;
+
+// CHECK-lABEL: @non_zero_eq
+#[no_mangle]
+pub fn non_zero_eq(l: Option<NonZeroU32>, r: Option<NonZeroU32>) -> bool {
+    // CHECK: start:
+    // CHECK-NEXT: icmp eq i32
+    // CHECK-NEXT: ret i1
+    l == r
+}
+
+// CHECK-lABEL: @non_zero_signed_eq
+#[no_mangle]
+pub fn non_zero_signed_eq(l: Option<NonZeroI64>, r: Option<NonZeroI64>) -> bool {
+    // CHECK: start:
+    // CHECK-NEXT: icmp eq i64
+    // CHECK-NEXT: ret i1
+    l == r
+}
+
+// CHECK-lABEL: @non_null_eq
+#[no_mangle]
+pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool {
+    // CHECK: start:
+    // CHECK-NEXT: icmp eq {{(i8\*|ptr)}}
+    // CHECK-NEXT: ret i1
+    l == r
+}