Skip to content

Commit 6d3d07a

Browse files
Feature-flag doc tests so they run for core
1 parent 8342fe7 commit 6d3d07a

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

crates/core_simd/src/math.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ macro_rules! impl_uint_arith {
1010
/// # Examples
1111
/// ```
1212
/// # #![feature(portable_simd)]
13-
/// # use core_simd::*;
13+
/// # #[cfg(feature = "std")] use core_simd::Simd;
14+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
1415
#[doc = concat!("# use core::", stringify!($ty), "::MAX;")]
1516
/// let x = Simd::from_array([2, 1, 0, MAX]);
1617
/// let max = Simd::splat(MAX);
@@ -29,7 +30,8 @@ macro_rules! impl_uint_arith {
2930
/// # Examples
3031
/// ```
3132
/// # #![feature(portable_simd)]
32-
/// # use core_simd::*;
33+
/// # #[cfg(feature = "std")] use core_simd::Simd;
34+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
3335
#[doc = concat!("# use core::", stringify!($ty), "::MAX;")]
3436
/// let x = Simd::from_array([2, 1, 0, MAX]);
3537
/// let max = Simd::splat(MAX);
@@ -54,7 +56,8 @@ macro_rules! impl_int_arith {
5456
/// # Examples
5557
/// ```
5658
/// # #![feature(portable_simd)]
57-
/// # use core_simd::*;
59+
/// # #[cfg(feature = "std")] use core_simd::Simd;
60+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
5861
#[doc = concat!("# use core::", stringify!($ty), "::{MIN, MAX};")]
5962
/// let x = Simd::from_array([MIN, 0, 1, MAX]);
6063
/// let max = Simd::splat(MAX);
@@ -73,7 +76,8 @@ macro_rules! impl_int_arith {
7376
/// # Examples
7477
/// ```
7578
/// # #![feature(portable_simd)]
76-
/// # use core_simd::*;
79+
/// # #[cfg(feature = "std")] use core_simd::Simd;
80+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
7781
#[doc = concat!("# use core::", stringify!($ty), "::{MIN, MAX};")]
7882
/// let x = Simd::from_array([MIN, -2, -1, MAX]);
7983
/// let max = Simd::splat(MAX);
@@ -92,7 +96,8 @@ macro_rules! impl_int_arith {
9296
/// # Examples
9397
/// ```
9498
/// # #![feature(portable_simd)]
95-
/// # use core_simd::*;
99+
/// # #[cfg(feature = "std")] use core_simd::Simd;
100+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
96101
#[doc = concat!("# use core::", stringify!($ty), "::{MIN, MAX};")]
97102
/// let xs = Simd::from_array([MIN, MIN +1, -5, 0]);
98103
/// assert_eq!(xs.abs(), Simd::from_array([MIN, MAX, 5, 0]));
@@ -110,7 +115,8 @@ macro_rules! impl_int_arith {
110115
/// # Examples
111116
/// ```
112117
/// # #![feature(portable_simd)]
113-
/// # use core_simd::*;
118+
/// # #[cfg(feature = "std")] use core_simd::Simd;
119+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
114120
#[doc = concat!("# use core::", stringify!($ty), "::{MIN, MAX};")]
115121
/// let xs = Simd::from_array([MIN, -2, 0, 3]);
116122
/// let unsat = xs.abs();
@@ -132,7 +138,8 @@ macro_rules! impl_int_arith {
132138
/// # Examples
133139
/// ```
134140
/// # #![feature(portable_simd)]
135-
/// # use core_simd::*;
141+
/// # #[cfg(feature = "std")] use core_simd::Simd;
142+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
136143
#[doc = concat!("# use core::", stringify!($ty), "::{MIN, MAX};")]
137144
/// let x = Simd::from_array([MIN, -2, 3, MAX]);
138145
/// let unsat = -x;

crates/core_simd/src/permute.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ macro_rules! impl_shuffle_lane {
1818
///
1919
/// ```
2020
/// #![feature(portable_simd)]
21-
/// # use core_simd::Simd;
21+
/// # #[cfg(feature = "std")] use core_simd::Simd;
22+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
2223
/// let a = Simd::from_array([1.0, 2.0, 3.0, 4.0]);
2324
/// let b = Simd::from_array([5.0, 6.0, 7.0, 8.0]);
2425
/// const IDXS: [u32; 4] = [4,0,3,7];
@@ -59,7 +60,8 @@ macro_rules! impl_shuffle_lane {
5960
///
6061
/// ```
6162
/// #![feature(portable_simd)]
62-
/// # use core_simd::Simd;
63+
/// # #[cfg(feature = "std")] use core_simd::Simd;
64+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
6365
/// let a = Simd::from_array([0, 1, 2, 3]);
6466
/// let b = Simd::from_array([4, 5, 6, 7]);
6567
/// let (x, y) = a.interleave(b);
@@ -111,7 +113,8 @@ macro_rules! impl_shuffle_lane {
111113
///
112114
/// ```
113115
/// #![feature(portable_simd)]
114-
/// # use core_simd::Simd;
116+
/// # #[cfg(feature = "std")] use core_simd::Simd;
117+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
115118
/// let a = Simd::from_array([0, 4, 1, 5]);
116119
/// let b = Simd::from_array([2, 6, 3, 7]);
117120
/// let (x, y) = a.deinterleave(b);

crates/core_simd/src/select.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ where
6161
///
6262
/// ```
6363
/// # #![feature(portable_simd)]
64-
/// # use core_simd::{Mask, Simd};
64+
/// # #[cfg(feature = "std")] use core_simd::{Simd, Mask};
65+
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, Mask};
6566
/// let a = Simd::from_array([0, 1, 2, 3]);
6667
/// let b = Simd::from_array([4, 5, 6, 7]);
6768
/// let mask = Mask::from_array([true, false, false, true]);
@@ -72,7 +73,8 @@ where
7273
/// `select` can also be used on masks:
7374
/// ```
7475
/// # #![feature(portable_simd)]
75-
/// # use core_simd::Mask;
76+
/// # #[cfg(feature = "std")] use core_simd::Mask;
77+
/// # #[cfg(not(feature = "std"))] use core::simd::Mask;
7678
/// let a = Mask::<i32, 4>::from_array([true, true, false, false]);
7779
/// let b = Mask::<i32, 4>::from_array([false, false, true, true]);
7880
/// let mask = Mask::<i32, 4>::from_array([true, false, false, true]);

crates/core_simd/src/vector.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ where
5353
/// If an index is out of bounds, that lane instead selects the value from the "or" vector.
5454
/// ```
5555
/// # #![feature(portable_simd)]
56-
/// # use core_simd::*;
56+
/// # #[cfg(feature = "std")] use core_simd::Simd;
57+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
5758
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
5859
/// let idxs = Simd::from_array([9, 3, 0, 5]);
5960
/// let alt = Simd::from_array([-5, -4, -3, -2]);
@@ -71,7 +72,8 @@ where
7172
/// Out-of-bounds indices instead use the default value for that lane (0).
7273
/// ```
7374
/// # #![feature(portable_simd)]
74-
/// # use core_simd::*;
75+
/// # #[cfg(feature = "std")] use core_simd::Simd;
76+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
7577
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
7678
/// let idxs = Simd::from_array([9, 3, 0, 5]);
7779
///
@@ -91,7 +93,8 @@ where
9193
/// Out-of-bounds or masked indices instead select the value from the "or" vector.
9294
/// ```
9395
/// # #![feature(portable_simd)]
94-
/// # use core_simd::*;
96+
/// # #[cfg(feature = "std")] use core_simd::{Simd, Mask};
97+
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, Mask};
9598
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
9699
/// let idxs = Simd::from_array([9, 3, 0, 5]);
97100
/// let alt = Simd::from_array([-5, -4, -3, -2]);
@@ -121,7 +124,8 @@ where
121124
/// `scatter` writes "in order", so if an index receives two writes, only the last is guaranteed.
122125
/// ```
123126
/// # #![feature(portable_simd)]
124-
/// # use core_simd::*;
127+
/// # #[cfg(feature = "std")] use core_simd::Simd;
128+
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
125129
/// let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
126130
/// let idxs = Simd::from_array([9, 3, 0, 0]);
127131
/// let vals = Simd::from_array([-27, 82, -41, 124]);
@@ -139,7 +143,8 @@ where
139143
/// `scatter_select` writes "in order", so if an index receives two writes, only the last is guaranteed.
140144
/// ```
141145
/// # #![feature(portable_simd)]
142-
/// # use core_simd::*;
146+
/// # #[cfg(feature = "std")] use core_simd::{Simd, Mask};
147+
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, Mask};
143148
/// let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
144149
/// let idxs = Simd::from_array([9, 3, 0, 0]);
145150
/// let vals = Simd::from_array([-27, 82, -41, 124]);

0 commit comments

Comments
 (0)