Skip to content

Commit bebcb9d

Browse files
committed
Add test for Ord impl for Option::NonZero
1 parent bc7512e commit bebcb9d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/codegen/option-niche-eq.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> b
2424
l == r
2525
}
2626

27+
// Test for #49892
28+
// This currently relies on a manual implementation of `PartialOrd`/`Ord` for `Option`
29+
// Once LLVM is better able to optimize this pattern, we can return to using a derive.
30+
// CHECK-LABEL: @non_zero_ord
31+
#[no_mangle]
32+
pub fn non_zero_ord(a: Option<NonZero<u32>>, b: Option<NonZero<u32>>) -> bool {
33+
// CHECK: start:
34+
// CHECK-NEXT: icmp ult i32
35+
// CHECK-NEXT: ret i1
36+
a < b
37+
}
38+
2739
// CHECK-LABEL: @non_null_eq
2840
#[no_mangle]
2941
pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool {

0 commit comments

Comments
 (0)