about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-26 08:02:40 +0000
committerbors <bors@rust-lang.org>2024-02-26 08:02:40 +0000
commit7cadf0b2da0d83d5d38c8eddb033acf1508942e0 (patch)
tree0cc9d713cfbed1a362010c110d1ba7f421ec2f07 /tests/codegen
parent8d74063672a9b1eb283e685cd059187f86d9373d (diff)
parentdb0b49b945f56356ee495cd8b909545d566ef92e (diff)
downloadrust-7cadf0b2da0d83d5d38c8eddb033acf1508942e0.tar.gz
rust-7cadf0b2da0d83d5d38c8eddb033acf1508942e0.zip
Auto merge of #3326 - rust-lang:rustup-2024-02-26, r=RalfJung
Automatic Rustup

also fixes https://github.com/rust-lang/miri/issues/3308
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/array-equality.rs4
-rw-r--r--tests/codegen/enum/enum-debug-niche-2.rs17
-rw-r--r--tests/codegen/function-arguments.rs8
-rw-r--r--tests/codegen/intrinsics/transmute-niched.rs6
-rw-r--r--tests/codegen/issues/issue-119422.rs22
-rw-r--r--tests/codegen/loads.rs8
-rw-r--r--tests/codegen/option-as-slice.rs9
-rw-r--r--tests/codegen/option-nonzero-eq.rs8
-rw-r--r--tests/codegen/slice-ref-equality.rs8
-rw-r--r--tests/codegen/transmute-optimized.rs6
10 files changed, 46 insertions, 50 deletions
diff --git a/tests/codegen/array-equality.rs b/tests/codegen/array-equality.rs
index 94354228886..5b85da1d4a0 100644
--- a/tests/codegen/array-equality.rs
+++ b/tests/codegen/array-equality.rs
@@ -1,7 +1,7 @@
 //@ compile-flags: -O -Z merge-functions=disabled
 //@ only-x86_64
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
 // CHECK-LABEL: @array_eq_value
 #[no_mangle]
@@ -63,7 +63,7 @@ pub fn array_eq_zero_short(x: [u16; 3]) -> bool {
 
 // CHECK-LABEL: @array_eq_none_short(i40
 #[no_mangle]
-pub fn array_eq_none_short(x: [Option<std::num::NonZeroU8>; 5]) -> bool {
+pub fn array_eq_none_short(x: [Option<std::num::NonZero<u8>>; 5]) -> bool {
     // CHECK-NEXT: start:
     // CHECK-NEXT: %[[EQ:.+]] = icmp eq i40 %0, 0
     // CHECK-NEXT: ret i1 %[[EQ]]
diff --git a/tests/codegen/enum/enum-debug-niche-2.rs b/tests/codegen/enum/enum-debug-niche-2.rs
index 4315741e0bd..25871885e7e 100644
--- a/tests/codegen/enum/enum-debug-niche-2.rs
+++ b/tests/codegen/enum/enum-debug-niche-2.rs
@@ -1,20 +1,17 @@
-// This tests that optimized enum debug info accurately reflects the enum layout.
-// This is ignored for the fallback mode on MSVC due to problems with PDB.
-
-//
-//@ ignore-msvc
-
+//! This tests that optimized enum debug info accurately reflects the enum layout.
+//! This is ignored for the fallback mode on MSVC due to problems with PDB.
+//!
 //@ compile-flags: -g -C no-prepopulate-passes
-
+//@ ignore-msvc
+//
 // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
 // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}}
 // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}}
-
-#![feature(never_type)]
+#![feature(generic_nonzero, never_type)]
 
 #[derive(Copy, Clone)]
 pub struct Entity {
-    private: std::num::NonZeroU32,
+    private: std::num::NonZero<u32>,
 }
 
 #[derive(Copy, Clone, PartialEq, Eq)]
diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs
index 88cedcf46b6..b75c188f51a 100644
--- a/tests/codegen/function-arguments.rs
+++ b/tests/codegen/function-arguments.rs
@@ -1,10 +1,10 @@
 //@ compile-flags: -O -C no-prepopulate-passes
-
 #![crate_type = "lib"]
 #![feature(dyn_star)]
+#![feature(generic_nonzero)]
 
 use std::mem::MaybeUninit;
-use std::num::NonZeroU64;
+use std::num::NonZero;
 use std::marker::PhantomPinned;
 use std::ptr::NonNull;
 
@@ -70,13 +70,13 @@ pub fn int(x: u64) -> u64 {
 
 // CHECK: noundef i64 @nonzero_int(i64 noundef %x)
 #[no_mangle]
-pub fn nonzero_int(x: NonZeroU64) -> NonZeroU64 {
+pub fn nonzero_int(x: NonZero<u64>) -> NonZero<u64> {
   x
 }
 
 // CHECK: noundef i64 @option_nonzero_int(i64 noundef %x)
 #[no_mangle]
-pub fn option_nonzero_int(x: Option<NonZeroU64>) -> Option<NonZeroU64> {
+pub fn option_nonzero_int(x: Option<NonZero<u64>>) -> Option<NonZero<u64>> {
   x
 }
 
diff --git a/tests/codegen/intrinsics/transmute-niched.rs b/tests/codegen/intrinsics/transmute-niched.rs
index 7c448c82e4b..b5e0da1b2f5 100644
--- a/tests/codegen/intrinsics/transmute-niched.rs
+++ b/tests/codegen/intrinsics/transmute-niched.rs
@@ -2,11 +2,11 @@
 //@ [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes
 //@ [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes
 //@ only-64bit (so I don't need to worry about usize)
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
 use std::mem::transmute;
-use std::num::NonZeroU32;
+use std::num::NonZero;
 
 #[repr(u8)]
 pub enum SmallEnum {
@@ -130,7 +130,7 @@ pub unsafe fn check_enum_to_char(x: Minus100ToPlus100) -> char {
 
 // CHECK-LABEL: @check_swap_pair(
 #[no_mangle]
-pub unsafe fn check_swap_pair(x: (char, NonZeroU32)) -> (NonZeroU32, char) {
+pub unsafe fn check_swap_pair(x: (char, NonZero<u32>)) -> (NonZero<u32>, char) {
     // OPT: %0 = icmp ule i32 %x.0, 1114111
     // OPT: call void @llvm.assume(i1 %0)
     // OPT: %1 = icmp uge i32 %x.0, 1
diff --git a/tests/codegen/issues/issue-119422.rs b/tests/codegen/issues/issue-119422.rs
index 937fdcf28f5..19480b4dc9e 100644
--- a/tests/codegen/issues/issue-119422.rs
+++ b/tests/codegen/issues/issue-119422.rs
@@ -1,13 +1,13 @@
 //! This test checks that compiler don't generate useless compares to zeros
-//! for NonZero integer types.
-
+//! for `NonZero` integer types.
+//!
 //@ compile-flags: -O --edition=2021 -Zmerge-functions=disabled
 //@ only-64bit (because the LLVM type of i64 for usize shows up)
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
-use core::num::*;
 use core::ptr::NonNull;
+use core::num::NonZero;
 
 // CHECK-LABEL: @check_non_null
 #[no_mangle]
@@ -18,7 +18,7 @@ pub fn check_non_null(x: NonNull<u8>) -> bool {
 
 // CHECK-LABEL: @equals_zero_is_false_u8
 #[no_mangle]
-pub fn equals_zero_is_false_u8(x: NonZeroU8) -> bool {
+pub fn equals_zero_is_false_u8(x: NonZero<u8>) -> bool {
     // CHECK-NOT: br
     // CHECK: ret i1 false
     // CHECK-NOT: br
@@ -27,7 +27,7 @@ pub fn equals_zero_is_false_u8(x: NonZeroU8) -> bool {
 
 // CHECK-LABEL: @not_equals_zero_is_true_u8
 #[no_mangle]
-pub fn not_equals_zero_is_true_u8(x: NonZeroU8) -> bool {
+pub fn not_equals_zero_is_true_u8(x: NonZero<u8>) -> bool {
     // CHECK-NOT: br
     // CHECK: ret i1 true
     // CHECK-NOT: br
@@ -36,7 +36,7 @@ pub fn not_equals_zero_is_true_u8(x: NonZeroU8) -> bool {
 
 // CHECK-LABEL: @equals_zero_is_false_i8
 #[no_mangle]
-pub fn equals_zero_is_false_i8(x: NonZeroI8) -> bool {
+pub fn equals_zero_is_false_i8(x: NonZero<i8>) -> bool {
     // CHECK-NOT: br
     // CHECK: ret i1 false
     // CHECK-NOT: br
@@ -45,7 +45,7 @@ pub fn equals_zero_is_false_i8(x: NonZeroI8) -> bool {
 
 // CHECK-LABEL: @not_equals_zero_is_true_i8
 #[no_mangle]
-pub fn not_equals_zero_is_true_i8(x: NonZeroI8) -> bool {
+pub fn not_equals_zero_is_true_i8(x: NonZero<i8>) -> bool {
     // CHECK-NOT: br
     // CHECK: ret i1 true
     // CHECK-NOT: br
@@ -54,7 +54,7 @@ pub fn not_equals_zero_is_true_i8(x: NonZeroI8) -> bool {
 
 // CHECK-LABEL: @usize_try_from_u32
 #[no_mangle]
-pub fn usize_try_from_u32(x: NonZeroU32) -> NonZeroUsize {
+pub fn usize_try_from_u32(x: NonZero<u32>) -> NonZero<usize> {
     // CHECK-NOT: br
     // CHECK: zext i32 %{{.*}} to i64
     // CHECK-NOT: br
@@ -64,7 +64,7 @@ pub fn usize_try_from_u32(x: NonZeroU32) -> NonZeroUsize {
 
 // CHECK-LABEL: @isize_try_from_i32
 #[no_mangle]
-pub fn isize_try_from_i32(x: NonZeroI32) -> NonZeroIsize {
+pub fn isize_try_from_i32(x: NonZero<i32>) -> NonZero<isize> {
     // CHECK-NOT: br
     // CHECK: sext i32 %{{.*}} to i64
     // CHECK-NOT: br
@@ -74,7 +74,7 @@ pub fn isize_try_from_i32(x: NonZeroI32) -> NonZeroIsize {
 
 // CHECK-LABEL: @u64_from_nonzero_is_not_zero
 #[no_mangle]
-pub fn u64_from_nonzero_is_not_zero(x: NonZeroU64)->bool {
+pub fn u64_from_nonzero_is_not_zero(x: NonZero<u64>)->bool {
     // CHECK-NOT: br
     // CHECK: ret i1 false
     // CHECK-NOT: br
diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs
index 0471d83c25a..b86b3dd3a19 100644
--- a/tests/codegen/loads.rs
+++ b/tests/codegen/loads.rs
@@ -1,9 +1,9 @@
 //@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
 use std::mem::MaybeUninit;
-use std::num::NonZeroU16;
+use std::num::NonZero;
 
 pub struct Bytes {
     a: u8,
@@ -99,14 +99,14 @@ pub fn load_int(x: &u16) -> u16 {
 
 // CHECK-LABEL: @load_nonzero_int
 #[no_mangle]
-pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 {
+pub fn load_nonzero_int(x: &NonZero<u16>) -> NonZero<u16> {
     // CHECK: load i16, ptr %x, align 2, !range ![[NONZEROU16_RANGE:[0-9]+]], !noundef !{{[0-9]+}}
     *x
 }
 
 // CHECK-LABEL: @load_option_nonzero_int
 #[no_mangle]
-pub fn load_option_nonzero_int(x: &Option<NonZeroU16>) -> Option<NonZeroU16> {
+pub fn load_option_nonzero_int(x: &Option<NonZero<u16>>) -> Option<NonZero<u16>> {
     // CHECK: load i16, ptr %x, align 2, !noundef ![[NOUNDEF]]{{$}}
     *x
 }
diff --git a/tests/codegen/option-as-slice.rs b/tests/codegen/option-as-slice.rs
index 990ec1d1f66..14a39243607 100644
--- a/tests/codegen/option-as-slice.rs
+++ b/tests/codegen/option-as-slice.rs
@@ -1,14 +1,13 @@
 //@ compile-flags: -O -Z randomize-layout=no
 //@ only-x86_64
 //@ ignore-llvm-version: 16.0.0
-// ^ needs https://reviews.llvm.org/D146149 in 16.0.1
-
+//  ^-- needs https://reviews.llvm.org/D146149 in 16.0.1
 #![crate_type = "lib"]
-#![feature(option_as_slice)]
+#![feature(generic_nonzero)]
 
 extern crate core;
 
-use core::num::NonZeroU64;
+use core::num::NonZero;
 use core::option::Option;
 
 // CHECK-LABEL: @u64_opt_as_slice
@@ -23,7 +22,7 @@ pub fn u64_opt_as_slice(o: &Option<u64>) -> &[u64] {
 
 // CHECK-LABEL: @nonzero_u64_opt_as_slice
 #[no_mangle]
-pub fn nonzero_u64_opt_as_slice(o: &Option<NonZeroU64>) -> &[NonZeroU64] {
+pub fn nonzero_u64_opt_as_slice(o: &Option<NonZero<u64>>) -> &[NonZero<u64>] {
     // CHECK-NOT: select
     // CHECK-NOT: br
     // CHECK-NOT: switch
diff --git a/tests/codegen/option-nonzero-eq.rs b/tests/codegen/option-nonzero-eq.rs
index f6be90a5dde..f637b1aef97 100644
--- a/tests/codegen/option-nonzero-eq.rs
+++ b/tests/codegen/option-nonzero-eq.rs
@@ -1,18 +1,18 @@
 //@ compile-flags: -O -Zmerge-functions=disabled
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
 extern crate core;
 use core::cmp::Ordering;
-use core::num::{NonZeroU32, NonZeroI64};
 use core::ptr::NonNull;
+use core::num::NonZero;
 
 // See also tests/assembly/option-nonzero-eq.rs, for cases with `assume`s in the
 // LLVM and thus don't optimize down clearly here, but do in assembly.
 
 // CHECK-lABEL: @non_zero_eq
 #[no_mangle]
-pub fn non_zero_eq(l: Option<NonZeroU32>, r: Option<NonZeroU32>) -> bool {
+pub fn non_zero_eq(l: Option<NonZero<u32>>, r: Option<NonZero<u32>>) -> bool {
     // CHECK: start:
     // CHECK-NEXT: icmp eq i32
     // CHECK-NEXT: ret i1
@@ -21,7 +21,7 @@ pub fn non_zero_eq(l: Option<NonZeroU32>, r: Option<NonZeroU32>) -> bool {
 
 // CHECK-lABEL: @non_zero_signed_eq
 #[no_mangle]
-pub fn non_zero_signed_eq(l: Option<NonZeroI64>, r: Option<NonZeroI64>) -> bool {
+pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> bool {
     // CHECK: start:
     // CHECK-NEXT: icmp eq i64
     // CHECK-NEXT: ret i1
diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs
index 371e685ec6c..85d9c34a30b 100644
--- a/tests/codegen/slice-ref-equality.rs
+++ b/tests/codegen/slice-ref-equality.rs
@@ -1,8 +1,8 @@
 //@ compile-flags: -O -Zmerge-functions=disabled
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
-use std::num::{NonZeroI16, NonZeroU32};
+use std::num::NonZero;
 
 // #71602 reported a simple array comparison just generating a loop.
 // This was originally fixed by ensuring it generates a single bcmp,
@@ -70,7 +70,7 @@ fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool {
 // CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
 // CHECK-SAME: [[USIZE]] noundef %3
 #[no_mangle]
-fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool {
+fn eq_slice_of_nonzero(x: &[NonZero<i32>], y: &[NonZero<i32>]) -> bool {
     // CHECK: icmp eq [[USIZE]] %1, %3
     // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2
     // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
@@ -82,7 +82,7 @@ fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool {
 // CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
 // CHECK-SAME: [[USIZE]] noundef %3
 #[no_mangle]
-fn eq_slice_of_option_of_nonzero(x: &[Option<NonZeroI16>], y: &[Option<NonZeroI16>]) -> bool {
+fn eq_slice_of_option_of_nonzero(x: &[Option<NonZero<i16>>], y: &[Option<NonZero<i16>>]) -> bool {
     // CHECK: icmp eq [[USIZE]] %1, %3
     // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1
     // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs
index 9217def76b5..1a5f53e625a 100644
--- a/tests/codegen/transmute-optimized.rs
+++ b/tests/codegen/transmute-optimized.rs
@@ -1,6 +1,6 @@
 //@ compile-flags: -O -Z merge-functions=disabled
-
 #![crate_type = "lib"]
+#![feature(generic_nonzero)]
 
 // This tests that LLVM can optimize based on the niches in the source or
 // destination types for transmutes.
@@ -33,7 +33,7 @@ pub fn non_null_is_null(x: std::ptr::NonNull<i32>) -> bool {
 
 // CHECK-LABEL: i1 @non_zero_is_null(
 #[no_mangle]
-pub fn non_zero_is_null(x: std::num::NonZeroUsize) -> bool {
+pub fn non_zero_is_null(x: std::num::NonZero<usize>) -> bool {
     // CHECK: ret i1 false
     let p: *const i32 = unsafe { std::mem::transmute(x) };
     p.is_null()
@@ -72,7 +72,7 @@ pub fn normal_div(a: u32, b: u32) -> u32 {
 
 // CHECK-LABEL: i32 @div_transmute_nonzero(i32
 #[no_mangle]
-pub fn div_transmute_nonzero(a: u32, b: std::num::NonZeroI32) -> u32 {
+pub fn div_transmute_nonzero(a: u32, b: std::num::NonZero<i32>) -> u32 {
     // CHECK-NOT: call core::panicking::panic
     // CHECK: %[[R:.+]] = udiv i32 %a, %b
     // CHECK-NEXT: ret i32 %[[R]]