From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- third_party/rust/packed_simd/src/testing/macros.rs | 44 ------- third_party/rust/packed_simd/src/testing/utils.rs | 130 --------------------- 2 files changed, 174 deletions(-) delete mode 100644 third_party/rust/packed_simd/src/testing/macros.rs delete mode 100644 third_party/rust/packed_simd/src/testing/utils.rs (limited to 'third_party/rust/packed_simd/src/testing') diff --git a/third_party/rust/packed_simd/src/testing/macros.rs b/third_party/rust/packed_simd/src/testing/macros.rs deleted file mode 100644 index 7bc4268b90..0000000000 --- a/third_party/rust/packed_simd/src/testing/macros.rs +++ /dev/null @@ -1,44 +0,0 @@ -//! Testing macros - -macro_rules! test_if { - ($cfg_tt:tt: $it:item) => { - #[cfg(any( - // Test everything if: - // - // * tests are enabled, - // * no features about exclusively testing - // specific vector classes are enabled - all(test, not(any( - test_v16, - test_v32, - test_v64, - test_v128, - test_v256, - test_v512, - test_none, // disables all tests - ))), - // Test if: - // - // * tests are enabled - // * a particular cfg token tree returns true - all(test, $cfg_tt), - ))] - $it - }; -} - -#[cfg(test)] -#[allow(unused)] -macro_rules! ref_ { - ($anything:tt) => { - &$anything - }; -} - -#[cfg(test)] -#[allow(unused)] -macro_rules! ref_mut_ { - ($anything:tt) => { - &mut $anything - }; -} diff --git a/third_party/rust/packed_simd/src/testing/utils.rs b/third_party/rust/packed_simd/src/testing/utils.rs deleted file mode 100644 index 7d8f395739..0000000000 --- a/third_party/rust/packed_simd/src/testing/utils.rs +++ /dev/null @@ -1,130 +0,0 @@ -//! Testing utilities - -#![allow(dead_code)] -// FIXME: Or don't. But it's true this is a problematic comparison. -#![allow(clippy::neg_cmp_op_on_partial_ord)] - -use crate::{cmp::PartialOrd, fmt::Debug, LexicographicallyOrdered}; - -/// Tests PartialOrd for `a` and `b` where `a < b` is true. -pub fn test_lt(a: LexicographicallyOrdered, b: LexicographicallyOrdered) -where - LexicographicallyOrdered: Debug + PartialOrd, -{ - assert!(a < b, "{:?}, {:?}", a, b); - assert!(b > a, "{:?}, {:?}", a, b); - - assert!(!(a == b), "{:?}, {:?}", a, b); - assert_ne!(a, b, "{:?}, {:?}", a, b); - - assert!(a <= b, "{:?}, {:?}", a, b); - assert!(b >= a, "{:?}, {:?}", a, b); - - // The elegance of the mathematical expression of irreflexivity is more - // than clippy can handle. - #[allow(clippy::eq_op)] - { - // Irreflexivity - assert!(!(a < a), "{:?}, {:?}", a, b); - assert!(!(b < b), "{:?}, {:?}", a, b); - assert!(!(a > a), "{:?}, {:?}", a, b); - assert!(!(b > b), "{:?}, {:?}", a, b); - - assert!(a <= a, "{:?}, {:?}", a, b); - assert!(b <= b, "{:?}, {:?}", a, b); - } -} - -/// Tests PartialOrd for `a` and `b` where `a <= b` is true. -pub fn test_le(a: LexicographicallyOrdered, b: LexicographicallyOrdered) -where - LexicographicallyOrdered: Debug + PartialOrd, -{ - assert!(a <= b, "{:?}, {:?}", a, b); - assert!(b >= a, "{:?}, {:?}", a, b); - - assert!(a <= b, "{:?}, {:?}", a, b); - assert!(b >= a, "{:?}, {:?}", a, b); - - if a == b { - assert!(!(a < b), "{:?}, {:?}", a, b); - assert!(!(b > a), "{:?}, {:?}", a, b); - - assert!(!(a != b), "{:?}, {:?}", a, b); - } else { - assert_ne!(a, b, "{:?}, {:?}", a, b); - test_lt(a, b); - } -} - -/// Test PartialOrd::partial_cmp for `a` and `b` returning `Ordering` -pub fn test_cmp( - a: LexicographicallyOrdered, - b: LexicographicallyOrdered, - o: Option, -) where - LexicographicallyOrdered: PartialOrd + Debug, - T: Debug + crate::sealed::Simd + Copy + Clone, - ::Element: Default + Copy + Clone + PartialOrd, -{ - assert!(T::LANES <= 64, "array length in these two arrays needs updating"); - let mut arr_a: [T::Element; 64] = [Default::default(); 64]; - let mut arr_b: [T::Element; 64] = [Default::default(); 64]; - - unsafe { crate::ptr::write_unaligned(arr_a.as_mut_ptr() as *mut LexicographicallyOrdered, a) } - unsafe { crate::ptr::write_unaligned(arr_b.as_mut_ptr() as *mut LexicographicallyOrdered, b) } - let expected = arr_a[0..T::LANES].partial_cmp(&arr_b[0..T::LANES]); - let result = a.partial_cmp(&b); - assert_eq!(expected, result, "{:?}, {:?}", a, b); - assert_eq!(o, result, "{:?}, {:?}", a, b); - match o { - Some(crate::cmp::Ordering::Less) => { - test_lt(a, b); - test_le(a, b); - } - Some(crate::cmp::Ordering::Greater) => { - test_lt(b, a); - test_le(b, a); - } - Some(crate::cmp::Ordering::Equal) => { - assert!(a == b, "{:?}, {:?}", a, b); - assert!(!(a != b), "{:?}, {:?}", a, b); - assert!(!(a < b), "{:?}, {:?}", a, b); - assert!(!(b < a), "{:?}, {:?}", a, b); - assert!(!(a > b), "{:?}, {:?}", a, b); - assert!(!(b > a), "{:?}, {:?}", a, b); - - test_le(a, b); - test_le(b, a); - } - None => { - assert!(!(a == b), "{:?}, {:?}", a, b); - assert!(!(a != b), "{:?}, {:?}", a, b); - assert!(!(a < b), "{:?}, {:?}", a, b); - assert!(!(a > b), "{:?}, {:?}", a, b); - assert!(!(b < a), "{:?}, {:?}", a, b); - assert!(!(b > a), "{:?}, {:?}", a, b); - assert!(!(a <= b), "{:?}, {:?}", a, b); - assert!(!(b <= a), "{:?}, {:?}", a, b); - assert!(!(a >= b), "{:?}, {:?}", a, b); - assert!(!(b >= a), "{:?}, {:?}", a, b); - } - } -} - -// Returns a tuple containing two distinct pointer values of the same type as -// the element type of the Simd vector `$id`. -#[allow(unused)] -macro_rules! ptr_vals { - ($id:ty) => { - // expands to an expression - #[allow(unused_unsafe)] - unsafe { - // all bits cleared - let clear: <$id as sealed::Simd>::Element = crate::mem::zeroed(); - // all bits set - let set: <$id as sealed::Simd>::Element = crate::mem::transmute(-1_isize); - (clear, set) - } - }; -} -- cgit v1.2.3