Skip to content

Commit ab8eec7

Browse files
Fixup import pathing for core
This changes simd_swizzle! to a decl_macro to give it a path, so it can be imported using a path and not the crate root. It also adds various uses that were missed and adjusts paths.
1 parent 5b4282e commit ab8eec7

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

crates/core_simd/examples/matrix_inversion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Code ported from the `packed_simd` crate
33
// Run this code with `cargo test --example matrix_inversion`
44
#![feature(array_chunks, portable_simd)]
5-
use core_simd::Which::*;
6-
use core_simd::*;
5+
use core_simd::simd::*;
6+
use Which::*;
77

88
// Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^)
99
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]

crates/core_simd/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
22
#![feature(
33
const_fn_trait_bound,
4-
const_panic,
4+
decl_macro,
55
platform_intrinsics,
66
repr_simd,
77
simd_ffi,

crates/core_simd/src/swizzle.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::simd::intrinsics;
2-
use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
2+
use crate::simd::{LaneCount, Simd, SimdElement, SupportedLaneCount};
33

44
/// Constructs a new vector by selecting values from the lanes of the source vector or vectors to use.
55
///
@@ -12,7 +12,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
1212
/// ## One source vector
1313
/// ```
1414
/// # #![feature(portable_simd)]
15-
/// # use core_simd::{Simd, simd_swizzle};
15+
/// # #[cfg(feature = "std")] use core_simd::{Simd, simd_swizzle};
16+
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, simd_swizzle};
1617
/// let v = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
1718
///
1819
/// // Keeping the same size
@@ -27,7 +28,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
2728
/// ## Two source vectors
2829
/// ```
2930
/// # #![feature(portable_simd)]
30-
/// # use core_simd::{Simd, simd_swizzle, Which};
31+
/// # #[cfg(feature = "std")] use core_simd::{Simd, simd_swizzle, Which};
32+
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, simd_swizzle, Which};
3133
/// use Which::*;
3234
/// let a = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
3335
/// let b = Simd::<f32, 4>::from_array([4., 5., 6., 7.]);
@@ -40,11 +42,11 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
4042
/// let r = simd_swizzle!(a, b, [First(0), Second(0)]);
4143
/// assert_eq!(r.to_array(), [0., 4.]);
4244
/// ```
43-
#[macro_export]
44-
macro_rules! simd_swizzle {
45-
{
45+
#[allow(unused_macros)]
46+
pub macro simd_swizzle {
47+
(
4648
$vector:expr, $index:expr $(,)?
47-
} => {
49+
) => {
4850
{
4951
use $crate::simd::Swizzle;
5052
struct Impl;
@@ -53,10 +55,10 @@ macro_rules! simd_swizzle {
5355
}
5456
Impl::swizzle($vector)
5557
}
56-
};
57-
{
58+
},
59+
(
5860
$first:expr, $second:expr, $index:expr $(,)?
59-
} => {
61+
) => {
6062
{
6163
use $crate::simd::{Which, Swizzle2};
6264
struct Impl;
@@ -262,7 +264,8 @@ where
262264
///
263265
/// ```
264266
/// #![feature(portable_simd)]
265-
/// # use core_simd::Simd;
267+
/// # #[cfg(feature = "std")] use core_simd::Simd;
268+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
266269
/// let a = Simd::from_array([0, 1, 2, 3]);
267270
/// let b = Simd::from_array([4, 5, 6, 7]);
268271
/// let (x, y) = a.interleave(b);
@@ -324,7 +327,8 @@ where
324327
///
325328
/// ```
326329
/// #![feature(portable_simd)]
327-
/// # use core_simd::Simd;
330+
/// # #[cfg(feature = "std")] use core_simd::Simd;
331+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
328332
/// let a = Simd::from_array([0, 4, 1, 5]);
329333
/// let b = Simd::from_array([2, 6, 3, 7]);
330334
/// let (x, y) = a.deinterleave(b);

0 commit comments

Comments
 (0)