Skip to content

Commit

Permalink
Merge pull request #317 from rust-lang/fix-exports
Browse files Browse the repository at this point in the history
Remove reexport of simd::*
  • Loading branch information
calebzulawski authored Nov 28, 2022
2 parents 6e30c6e + db8b23c commit 645ab61
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 45 deletions.
1 change: 0 additions & 1 deletion crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
#[path = "mod.rs"]
mod core_simd;
pub use self::core_simd::simd;
pub use simd::*;
2 changes: 1 addition & 1 deletion crates/core_simd/tests/autoderef.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test that we handle all our "auto-deref" cases correctly.
#![feature(portable_simd)]
use core_simd::f32x4;
use core_simd::simd::f32x4;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/tests/mask_ops_impl/mask_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ macro_rules! mask_tests {
{ $vector:ident, $lanes:literal } => {
#[cfg(test)]
mod $vector {
use core_simd::$vector as Vector;
use core_simd::simd::$vector as Vector;
const LANES: usize = $lanes;

#[cfg(target_arch = "wasm32")]
Expand Down
59 changes: 31 additions & 28 deletions crates/core_simd/tests/masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ macro_rules! test_mask_api {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;

use core_simd::simd::Mask;

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn set_and_test() {
let values = [true, false, false, true, false, false, true, false];
let mut mask = core_simd::Mask::<$type, 8>::splat(false);
let mut mask = Mask::<$type, 8>::splat(false);
for (lane, value) in values.iter().copied().enumerate() {
mask.set(lane, value);
}
Expand All @@ -29,90 +31,90 @@ macro_rules! test_mask_api {
#[test]
#[should_panic]
fn set_invalid_lane() {
let mut mask = core_simd::Mask::<$type, 8>::splat(false);
let mut mask = Mask::<$type, 8>::splat(false);
mask.set(8, true);
let _ = mask;
}

#[test]
#[should_panic]
fn test_invalid_lane() {
let mask = core_simd::Mask::<$type, 8>::splat(false);
let mask = Mask::<$type, 8>::splat(false);
let _ = mask.test(8);
}

#[test]
fn any() {
assert!(!core_simd::Mask::<$type, 8>::splat(false).any());
assert!(core_simd::Mask::<$type, 8>::splat(true).any());
let mut v = core_simd::Mask::<$type, 8>::splat(false);
assert!(!Mask::<$type, 8>::splat(false).any());
assert!(Mask::<$type, 8>::splat(true).any());
let mut v = Mask::<$type, 8>::splat(false);
v.set(2, true);
assert!(v.any());
}

#[test]
fn all() {
assert!(!core_simd::Mask::<$type, 8>::splat(false).all());
assert!(core_simd::Mask::<$type, 8>::splat(true).all());
let mut v = core_simd::Mask::<$type, 8>::splat(false);
assert!(!Mask::<$type, 8>::splat(false).all());
assert!(Mask::<$type, 8>::splat(true).all());
let mut v = Mask::<$type, 8>::splat(false);
v.set(2, true);
assert!(!v.all());
}

#[test]
fn roundtrip_int_conversion() {
let values = [true, false, false, true, false, false, true, false];
let mask = core_simd::Mask::<$type, 8>::from_array(values);
let mask = Mask::<$type, 8>::from_array(values);
let int = mask.to_int();
assert_eq!(int.to_array(), [-1, 0, 0, -1, 0, 0, -1, 0]);
assert_eq!(core_simd::Mask::<$type, 8>::from_int(int), mask);
assert_eq!(Mask::<$type, 8>::from_int(int), mask);
}

#[test]
fn roundtrip_bitmask_conversion() {
use core_simd::ToBitMask;
use core_simd::simd::ToBitMask;
let values = [
true, false, false, true, false, false, true, false,
true, true, false, false, false, false, false, true,
];
let mask = core_simd::Mask::<$type, 16>::from_array(values);
let mask = Mask::<$type, 16>::from_array(values);
let bitmask = mask.to_bitmask();
assert_eq!(bitmask, 0b1000001101001001);
assert_eq!(core_simd::Mask::<$type, 16>::from_bitmask(bitmask), mask);
assert_eq!(Mask::<$type, 16>::from_bitmask(bitmask), mask);
}

#[test]
fn roundtrip_bitmask_conversion_short() {
use core_simd::ToBitMask;
use core_simd::simd::ToBitMask;

let values = [
false, false, false, true,
];
let mask = core_simd::Mask::<$type, 4>::from_array(values);
let mask = Mask::<$type, 4>::from_array(values);
let bitmask = mask.to_bitmask();
assert_eq!(bitmask, 0b1000);
assert_eq!(core_simd::Mask::<$type, 4>::from_bitmask(bitmask), mask);
assert_eq!(Mask::<$type, 4>::from_bitmask(bitmask), mask);

let values = [true, false];
let mask = core_simd::Mask::<$type, 2>::from_array(values);
let mask = Mask::<$type, 2>::from_array(values);
let bitmask = mask.to_bitmask();
assert_eq!(bitmask, 0b01);
assert_eq!(core_simd::Mask::<$type, 2>::from_bitmask(bitmask), mask);
assert_eq!(Mask::<$type, 2>::from_bitmask(bitmask), mask);
}

#[test]
fn cast() {
fn cast_impl<T: core_simd::MaskElement>()
fn cast_impl<T: core_simd::simd::MaskElement>()
where
core_simd::Mask<$type, 8>: Into<core_simd::Mask<T, 8>>,
Mask<$type, 8>: Into<Mask<T, 8>>,
{
let values = [true, false, false, true, false, false, true, false];
let mask = core_simd::Mask::<$type, 8>::from_array(values);
let mask = Mask::<$type, 8>::from_array(values);

let cast_mask = mask.cast::<T>();
assert_eq!(values, cast_mask.to_array());

let into_mask: core_simd::Mask<T, 8> = mask.into();
let into_mask: Mask<T, 8> = mask.into();
assert_eq!(values, into_mask.to_array());
}

Expand All @@ -126,15 +128,15 @@ macro_rules! test_mask_api {
#[cfg(feature = "generic_const_exprs")]
#[test]
fn roundtrip_bitmask_array_conversion() {
use core_simd::ToBitMaskArray;
use core_simd::simd::ToBitMaskArray;
let values = [
true, false, false, true, false, false, true, false,
true, true, false, false, false, false, false, true,
];
let mask = core_simd::Mask::<$type, 16>::from_array(values);
let mask = Mask::<$type, 16>::from_array(values);
let bitmask = mask.to_bitmask_array();
assert_eq!(bitmask, [0b01001001, 0b10000011]);
assert_eq!(core_simd::Mask::<$type, 16>::from_bitmask_array(bitmask), mask);
assert_eq!(Mask::<$type, 16>::from_bitmask_array(bitmask), mask);
}
}
}
Expand All @@ -150,9 +152,10 @@ mod mask_api {

#[test]
fn convert() {
use core_simd::simd::Mask;
let values = [true, false, false, true, false, false, true, false];
assert_eq!(
core_simd::Mask::<i8, 8>::from_array(values),
core_simd::Mask::<i32, 8>::from_array(values).into()
Mask::<i8, 8>::from_array(values),
Mask::<i32, 8>::from_array(values).into()
);
}
14 changes: 7 additions & 7 deletions crates/core_simd/tests/ops_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! impl_unary_op_test {
test_helpers::test_lanes! {
fn $fn<const LANES: usize>() {
test_helpers::test_unary_elementwise(
&<core_simd::Simd<$scalar, LANES> as core::ops::$trait>::$fn,
&<core_simd::simd::Simd<$scalar, LANES> as core::ops::$trait>::$fn,
&$scalar_fn,
&|_| true,
);
Expand All @@ -27,7 +27,7 @@ macro_rules! impl_binary_op_test {
{ $scalar:ty, $trait:ident :: $fn:ident, $trait_assign:ident :: $fn_assign:ident, $scalar_fn:expr } => {
mod $fn {
use super::*;
use core_simd::Simd;
use core_simd::simd::Simd;

test_helpers::test_lanes! {
fn normal<const LANES: usize>() {
Expand Down Expand Up @@ -64,7 +64,7 @@ macro_rules! impl_binary_checked_op_test {
{ $scalar:ty, $trait:ident :: $fn:ident, $trait_assign:ident :: $fn_assign:ident, $scalar_fn:expr, $check_fn:expr } => {
mod $fn {
use super::*;
use core_simd::Simd;
use core_simd::simd::Simd;

test_helpers::test_lanes! {
fn normal<const LANES: usize>() {
Expand Down Expand Up @@ -173,7 +173,7 @@ macro_rules! impl_signed_tests {
{ $scalar:tt } => {
mod $scalar {
use core_simd::simd::SimdInt;
type Vector<const LANES: usize> = core_simd::Simd<Scalar, LANES>;
type Vector<const LANES: usize> = core_simd::simd::Simd<Scalar, LANES>;
type Scalar = $scalar;

impl_common_integer_tests! { Vector, Scalar }
Expand Down Expand Up @@ -314,7 +314,7 @@ macro_rules! impl_unsigned_tests {
{ $scalar:tt } => {
mod $scalar {
use core_simd::simd::SimdUint;
type Vector<const LANES: usize> = core_simd::Simd<Scalar, LANES>;
type Vector<const LANES: usize> = core_simd::simd::Simd<Scalar, LANES>;
type Scalar = $scalar;

impl_common_integer_tests! { Vector, Scalar }
Expand Down Expand Up @@ -348,8 +348,8 @@ macro_rules! impl_unsigned_tests {
macro_rules! impl_float_tests {
{ $scalar:tt, $int_scalar:tt } => {
mod $scalar {
use core_simd::SimdFloat;
type Vector<const LANES: usize> = core_simd::Simd<Scalar, LANES>;
use core_simd::simd::SimdFloat;
type Vector<const LANES: usize> = core_simd::simd::Simd<Scalar, LANES>;
type Scalar = $scalar;

impl_unary_op_test!(Scalar, Neg::neg);
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/tests/pointers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(portable_simd, strict_provenance)]

use core_simd::{Simd, SimdConstPtr, SimdMutPtr};
use core_simd::simd::{Simd, SimdConstPtr, SimdMutPtr};

macro_rules! common_tests {
{ $constness:ident } => {
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/tests/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ macro_rules! float_rounding_test {
mod $scalar {
use std_float::StdFloat;

type Vector<const LANES: usize> = core_simd::Simd<$scalar, LANES>;
type Vector<const LANES: usize> = core_simd::simd::Simd<$scalar, LANES>;
type Scalar = $scalar;
type IntScalar = $int_scalar;

Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/tests/swizzle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(portable_simd)]
use core_simd::{Simd, Swizzle};
use core_simd::simd::{Simd, Swizzle};

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/tests/to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(incomplete_features)]
#![cfg(feature = "generic_const_exprs")]

use core_simd::Simd;
use core_simd::simd::Simd;

#[test]
fn byte_convert() {
Expand Down
2 changes: 1 addition & 1 deletion crates/core_simd/tests/try_from_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use wasm_bindgen_test::*;
#[cfg(target_arch = "wasm32")]
wasm_bindgen_test_configure!(run_in_browser);

use core_simd::i32x4;
use core_simd::simd::i32x4;

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
Expand Down
4 changes: 2 additions & 2 deletions crates/test_helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ macro_rules! test_lanes {

fn implementation<const $lanes: usize>()
where
core_simd::LaneCount<$lanes>: core_simd::SupportedLaneCount,
core_simd::simd::LaneCount<$lanes>: core_simd::simd::SupportedLaneCount,
$body

#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -508,7 +508,7 @@ macro_rules! test_lanes_panic {

fn implementation<const $lanes: usize>()
where
core_simd::LaneCount<$lanes>: core_simd::SupportedLaneCount,
core_simd::simd::LaneCount<$lanes>: core_simd::simd::SupportedLaneCount,
$body

$crate::test_lanes_helper!(
Expand Down

0 comments on commit 645ab61

Please sign in to comment.