diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2025-05-12 14:49:12 +0000 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2025-05-12 14:49:12 +0000 |
| commit | bebcb9da216ab439a8628219f8021b1770134a35 (patch) | |
| tree | 6f8d84d19a87cce1567ee9ca07e19a3ae4a291c8 /tests/codegen | |
| parent | bc7512ee6309ee7e8cacf87b94aa6d1f550c9d99 (diff) | |
Add test for Ord impl for Option::NonZero
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/option-niche-eq.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/codegen/option-niche-eq.rs b/tests/codegen/option-niche-eq.rs index 9c5ed9ce57a..2be9e2bc489 100644 --- a/tests/codegen/option-niche-eq.rs +++ b/tests/codegen/option-niche-eq.rs @@ -24,6 +24,18 @@ pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> b l == r } +// Test for #49892 +// This currently relies on a manual implementation of `PartialOrd`/`Ord` for `Option` +// Once LLVM is better able to optimize this pattern, we can return to using a derive. +// CHECK-LABEL: @non_zero_ord +#[no_mangle] +pub fn non_zero_ord(a: Option<NonZero<u32>>, b: Option<NonZero<u32>>) -> bool { + // CHECK: start: + // CHECK-NEXT: icmp ult i32 + // CHECK-NEXT: ret i1 + a < b +} + // CHECK-LABEL: @non_null_eq #[no_mangle] pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool { |
