Skip to content

Commit 2a8e802

Browse files
committed
Use generic NonZero in tests.
1 parent b6a23b8 commit 2a8e802

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+422
-418
lines changed

tests/codegen/array-equality.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn array_eq_zero_short(x: [u16; 3]) -> bool {
6363

6464
// CHECK-LABEL: @array_eq_none_short(i40
6565
#[no_mangle]
66-
pub fn array_eq_none_short(x: [Option<std::num::NonZeroU8>; 5]) -> bool {
66+
pub fn array_eq_none_short(x: [Option<std::num::NonZero<u8>>; 5]) -> bool {
6767
// CHECK-NEXT: start:
6868
// CHECK-NEXT: %[[EQ:.+]] = icmp eq i40 %0, 0
6969
// CHECK-NEXT: ret i1 %[[EQ]]

tests/codegen/enum/enum-debug-niche-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#[derive(Copy, Clone)]
1616
pub struct Entity {
17-
private: std::num::NonZeroU32,
17+
private: std::num::NonZero<u32>,
1818
}
1919

2020
#[derive(Copy, Clone, PartialEq, Eq)]

tests/codegen/function-arguments.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//@ compile-flags: -O -C no-prepopulate-passes
2-
32
#![crate_type = "lib"]
43
#![feature(dyn_star)]
4+
#![feature(generic_nonzero)]
55

66
use std::mem::MaybeUninit;
7-
use std::num::NonZeroU64;
7+
use std::num::NonZero;
88
use std::marker::PhantomPinned;
99
use std::ptr::NonNull;
1010

tests/codegen/intrinsics/transmute-niched.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
//@ [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes
33
//@ [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes
44
//@ only-64bit (so I don't need to worry about usize)
5-
65
#![crate_type = "lib"]
6+
#![feature(generic_nonzero)]
77

88
use std::mem::transmute;
9-
use std::num::NonZeroU32;
9+
use std::num::NonZero;
1010

1111
#[repr(u8)]
1212
pub enum SmallEnum {

tests/codegen/issues/issue-119422.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn check_non_null(x: NonNull<u8>) -> bool {
1818

1919
// CHECK-LABEL: @equals_zero_is_false_u8
2020
#[no_mangle]
21-
pub fn equals_zero_is_false_u8(x: NonZeroU8) -> bool {
21+
pub fn equals_zero_is_false_u8(x: NonZero<u8>) -> bool {
2222
// CHECK-NOT: br
2323
// CHECK: ret i1 false
2424
// CHECK-NOT: br
@@ -27,7 +27,7 @@ pub fn equals_zero_is_false_u8(x: NonZeroU8) -> bool {
2727

2828
// CHECK-LABEL: @not_equals_zero_is_true_u8
2929
#[no_mangle]
30-
pub fn not_equals_zero_is_true_u8(x: NonZeroU8) -> bool {
30+
pub fn not_equals_zero_is_true_u8(x: NonZero<u8>) -> bool {
3131
// CHECK-NOT: br
3232
// CHECK: ret i1 true
3333
// CHECK-NOT: br
@@ -36,7 +36,7 @@ pub fn not_equals_zero_is_true_u8(x: NonZeroU8) -> bool {
3636

3737
// CHECK-LABEL: @equals_zero_is_false_i8
3838
#[no_mangle]
39-
pub fn equals_zero_is_false_i8(x: NonZeroI8) -> bool {
39+
pub fn equals_zero_is_false_i8(x: NonZero<i8>) -> bool {
4040
// CHECK-NOT: br
4141
// CHECK: ret i1 false
4242
// CHECK-NOT: br
@@ -45,7 +45,7 @@ pub fn equals_zero_is_false_i8(x: NonZeroI8) -> bool {
4545

4646
// CHECK-LABEL: @not_equals_zero_is_true_i8
4747
#[no_mangle]
48-
pub fn not_equals_zero_is_true_i8(x: NonZeroI8) -> bool {
48+
pub fn not_equals_zero_is_true_i8(x: NonZero<i8>) -> bool {
4949
// CHECK-NOT: br
5050
// CHECK: ret i1 true
5151
// CHECK-NOT: br
@@ -54,7 +54,7 @@ pub fn not_equals_zero_is_true_i8(x: NonZeroI8) -> bool {
5454

5555
// CHECK-LABEL: @usize_try_from_u32
5656
#[no_mangle]
57-
pub fn usize_try_from_u32(x: NonZeroU32) -> NonZeroUsize {
57+
pub fn usize_try_from_u32(x: NonZero<u32>) -> NonZero<usize> {
5858
// CHECK-NOT: br
5959
// CHECK: zext i32 %{{.*}} to i64
6060
// CHECK-NOT: br
@@ -64,7 +64,7 @@ pub fn usize_try_from_u32(x: NonZeroU32) -> NonZeroUsize {
6464

6565
// CHECK-LABEL: @isize_try_from_i32
6666
#[no_mangle]
67-
pub fn isize_try_from_i32(x: NonZeroI32) -> NonZeroIsize {
67+
pub fn isize_try_from_i32(x: NonZero<i32>) -> NonZero<isize> {
6868
// CHECK-NOT: br
6969
// CHECK: sext i32 %{{.*}} to i64
7070
// CHECK-NOT: br
@@ -74,7 +74,7 @@ pub fn isize_try_from_i32(x: NonZeroI32) -> NonZeroIsize {
7474

7575
// CHECK-LABEL: @u64_from_nonzero_is_not_zero
7676
#[no_mangle]
77-
pub fn u64_from_nonzero_is_not_zero(x: NonZeroU64)->bool {
77+
pub fn u64_from_nonzero_is_not_zero(x: NonZero<u64>)->bool {
7878
// CHECK-NOT: br
7979
// CHECK: ret i1 false
8080
// CHECK-NOT: br

tests/codegen/loads.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0
2-
32
#![crate_type = "lib"]
3+
#![feature(generic_nonzero)]
44

55
use std::mem::MaybeUninit;
6-
use std::num::NonZeroU16;
6+
use std::num::NonZero;
77

88
pub struct Bytes {
99
a: u8,

tests/codegen/option-as-slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
extern crate core;
1010

11-
use core::num::NonZeroU64;
11+
use core::num::NonZero;
1212
use core::option::Option;
1313

1414
// CHECK-LABEL: @u64_opt_as_slice
@@ -23,7 +23,7 @@ pub fn u64_opt_as_slice(o: &Option<u64>) -> &[u64] {
2323

2424
// CHECK-LABEL: @nonzero_u64_opt_as_slice
2525
#[no_mangle]
26-
pub fn nonzero_u64_opt_as_slice(o: &Option<NonZeroU64>) -> &[NonZeroU64] {
26+
pub fn nonzero_u64_opt_as_slice(o: &Option<NonZero<u64>>) -> &[NonZero<u64>] {
2727
// CHECK-NOT: select
2828
// CHECK-NOT: br
2929
// CHECK-NOT: switch

tests/codegen/option-nonzero-eq.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
extern crate core;
66
use core::cmp::Ordering;
7-
use core::num::{NonZeroU32, NonZeroI64};
7+
use core::num::NonZero;
88
use core::ptr::NonNull;
99

1010
// See also tests/assembly/option-nonzero-eq.rs, for cases with `assume`s in the
1111
// LLVM and thus don't optimize down clearly here, but do in assembly.
1212

1313
// CHECK-lABEL: @non_zero_eq
1414
#[no_mangle]
15-
pub fn non_zero_eq(l: Option<NonZeroU32>, r: Option<NonZeroU32>) -> bool {
15+
pub fn non_zero_eq(l: Option<NonZero<u32>>, r: Option<NonZero<u32>>) -> bool {
1616
// CHECK: start:
1717
// CHECK-NEXT: icmp eq i32
1818
// CHECK-NEXT: ret i1
@@ -21,7 +21,7 @@ pub fn non_zero_eq(l: Option<NonZeroU32>, r: Option<NonZeroU32>) -> bool {
2121

2222
// CHECK-lABEL: @non_zero_signed_eq
2323
#[no_mangle]
24-
pub fn non_zero_signed_eq(l: Option<NonZeroI64>, r: Option<NonZeroI64>) -> bool {
24+
pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> bool {
2525
// CHECK: start:
2626
// CHECK-NEXT: icmp eq i64
2727
// CHECK-NEXT: ret i1

tests/codegen/slice-ref-equality.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@ compile-flags: -O -Zmerge-functions=disabled
22
//@ ignore-debug (the extra assertions get in the way)
3-
43
#![crate_type = "lib"]
4+
#![feature(generic_nonzero)]
55

6-
use std::num::{NonZeroI16, NonZeroU32};
6+
use std::num::NonZero;
77

88
// #71602 reported a simple array comparison just generating a loop.
99
// This was originally fixed by ensuring it generates a single bcmp,

tests/codegen/transmute-optimized.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn non_null_is_null(x: std::ptr::NonNull<i32>) -> bool {
3434

3535
// CHECK-LABEL: i1 @non_zero_is_null(
3636
#[no_mangle]
37-
pub fn non_zero_is_null(x: std::num::NonZeroUsize) -> bool {
37+
pub fn non_zero_is_null(x: std::num::NonZero<usize>) -> bool {
3838
// CHECK: ret i1 false
3939
let p: *const i32 = unsafe { std::mem::transmute(x) };
4040
p.is_null()
@@ -73,7 +73,7 @@ pub fn normal_div(a: u32, b: u32) -> u32 {
7373

7474
// CHECK-LABEL: i32 @div_transmute_nonzero(i32
7575
#[no_mangle]
76-
pub fn div_transmute_nonzero(a: u32, b: std::num::NonZeroI32) -> u32 {
76+
pub fn div_transmute_nonzero(a: u32, b: std::num::NonZero<i32>) -> u32 {
7777
// CHECK-NOT: call core::panicking::panic
7878
// CHECK: %[[R:.+]] = udiv i32 %a, %b
7979
// CHECK-NEXT: ret i32 %[[R]]

0 commit comments

Comments
 (0)