@@ -1926,7 +1926,10 @@ safety_comment! {
1926
1926
/// TODO(#429), TODO(https://github.com/rust-lang/rust/pull/115333): Cite
1927
1927
/// the Stable docs once they're available.
1928
1928
#[ cfg( feature = "alloc" ) ]
1929
- unsafe_impl!( T => FromZeroes for Option <Box <T >>) ;
1929
+ unsafe_impl!(
1930
+ #[ cfg_attr( doc_cfg, doc( cfg( feature = "alloc" ) ) ) ]
1931
+ T => FromZeroes for Option <Box <T >>
1932
+ ) ;
1930
1933
unsafe_impl!( T => FromZeroes for Option <& ' _ T >) ;
1931
1934
unsafe_impl!( T => FromZeroes for Option <& ' _ mut T >) ;
1932
1935
unsafe_impl!( T => FromZeroes for Option <NonNull <T >>) ;
@@ -2149,6 +2152,7 @@ safety_comment! {
2149
2152
// [1] https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
2150
2153
// [2] https://github.com/rust-lang/unsafe-code-guidelines/issues/38
2151
2154
#[ cfg( feature = "simd" ) ]
2155
+ #[ cfg_attr( doc_cfg, doc( cfg( feature = "simd" ) ) ) ]
2152
2156
mod simd {
2153
2157
/// Defines a module which implements `FromZeroes`, `FromBytes`, and
2154
2158
/// `AsBytes` for a set of types from a module in `core::arch`.
@@ -2160,7 +2164,9 @@ mod simd {
2160
2164
// target/feature combinations don't emit any impls
2161
2165
// and thus don't use this macro.
2162
2166
macro_rules! simd_arch_mod {
2163
- ( $arch: ident, $mod: ident, $( $typ: ident) ,* ) => {
2167
+ ( #[ cfg $cfg: tt] $arch: ident, $mod: ident, $( $typ: ident) ,* ) => {
2168
+ #[ cfg $cfg]
2169
+ #[ cfg_attr( doc_cfg, doc( cfg $cfg) ) ]
2164
2170
mod $mod {
2165
2171
use core:: arch:: $arch:: { $( $typ) ,* } ;
2166
2172
@@ -2175,48 +2181,51 @@ mod simd {
2175
2181
} ;
2176
2182
}
2177
2183
2178
- #[ cfg( target_arch = "x86" ) ]
2179
- simd_arch_mod ! ( x86, x86, __m128, __m128d, __m128i, __m256, __m256d, __m256i) ;
2180
- #[ cfg( all( feature = "simd-nightly" , target_arch = "x86" ) ) ]
2181
- simd_arch_mod ! ( x86, x86_nightly, __m512bh, __m512, __m512d, __m512i) ;
2182
- #[ cfg( target_arch = "x86_64" ) ]
2183
- simd_arch_mod ! ( x86_64, x86_64, __m128, __m128d, __m128i, __m256, __m256d, __m256i) ;
2184
- #[ cfg( all( feature = "simd-nightly" , target_arch = "x86_64" ) ) ]
2185
- simd_arch_mod ! ( x86_64, x86_64_nightly, __m512bh, __m512, __m512d, __m512i) ;
2186
- #[ cfg( target_arch = "wasm32" ) ]
2187
- simd_arch_mod ! ( wasm32, wasm32, v128) ;
2188
- #[ cfg( all( feature = "simd-nightly" , target_arch = "powerpc" ) ) ]
2189
- simd_arch_mod ! (
2190
- powerpc,
2191
- powerpc,
2192
- vector_bool_long,
2193
- vector_double,
2194
- vector_signed_long,
2195
- vector_unsigned_long
2196
- ) ;
2197
- #[ cfg( all( feature = "simd-nightly" , target_arch = "powerpc64" ) ) ]
2198
- simd_arch_mod ! (
2199
- powerpc64,
2200
- powerpc64,
2201
- vector_bool_long,
2202
- vector_double,
2203
- vector_signed_long,
2204
- vector_unsigned_long
2205
- ) ;
2206
- #[ cfg( target_arch = "aarch64" ) ]
2207
2184
#[ rustfmt:: skip]
2208
- simd_arch_mod ! (
2209
- aarch64, aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t,
2210
- int8x8x3_t, int8x8x4_t, int8x16_t, int8x16x2_t, int8x16x3_t, int8x16x4_t, int16x4_t,
2211
- int16x8_t, int32x2_t, int32x4_t, int64x1_t, int64x2_t, poly8x8_t, poly8x8x2_t, poly8x8x3_t,
2212
- poly8x8x4_t, poly8x16_t, poly8x16x2_t, poly8x16x3_t, poly8x16x4_t, poly16x4_t, poly16x8_t,
2213
- poly64x1_t, poly64x2_t, uint8x8_t, uint8x8x2_t, uint8x8x3_t, uint8x8x4_t, uint8x16_t,
2214
- uint8x16x2_t, uint8x16x3_t, uint8x16x4_t, uint16x4_t, uint16x8_t, uint32x2_t, uint32x4_t,
2215
- uint64x1_t, uint64x2_t
2216
- ) ;
2217
- #[ cfg( all( feature = "simd-nightly" , target_arch = "arm" ) ) ]
2218
- #[ rustfmt:: skip]
2219
- simd_arch_mod ! ( arm, arm, int8x4_t, uint8x4_t) ;
2185
+ const _: ( ) = {
2186
+ simd_arch_mod ! (
2187
+ #[ cfg( target_arch = "x86" ) ]
2188
+ x86, x86, __m128, __m128d, __m128i, __m256, __m256d, __m256i
2189
+ ) ;
2190
+ simd_arch_mod ! (
2191
+ #[ cfg( all( feature = "simd-nightly" , target_arch = "x86" ) ) ]
2192
+ x86, x86_nightly, __m512bh, __m512, __m512d, __m512i
2193
+ ) ;
2194
+ simd_arch_mod ! (
2195
+ #[ cfg( target_arch = "x86_64" ) ]
2196
+ x86_64, x86_64, __m128, __m128d, __m128i, __m256, __m256d, __m256i
2197
+ ) ;
2198
+ simd_arch_mod ! (
2199
+ #[ cfg( all( feature = "simd-nightly" , target_arch = "x86_64" ) ) ]
2200
+ x86_64, x86_64_nightly, __m512bh, __m512, __m512d, __m512i
2201
+ ) ;
2202
+ simd_arch_mod ! (
2203
+ #[ cfg( target_arch = "wasm32" ) ]
2204
+ wasm32, wasm32, v128
2205
+ ) ;
2206
+ simd_arch_mod ! (
2207
+ #[ cfg( all( feature = "simd-nightly" , target_arch = "powerpc" ) ) ]
2208
+ powerpc, powerpc, vector_bool_long, vector_double, vector_signed_long, vector_unsigned_long
2209
+ ) ;
2210
+ simd_arch_mod ! (
2211
+ #[ cfg( all( feature = "simd-nightly" , target_arch = "powerpc64" ) ) ]
2212
+ powerpc64, powerpc64, vector_bool_long, vector_double, vector_signed_long, vector_unsigned_long
2213
+ ) ;
2214
+ simd_arch_mod ! (
2215
+ #[ cfg( target_arch = "aarch64" ) ]
2216
+ aarch64, aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t,
2217
+ int8x8x3_t, int8x8x4_t, int8x16_t, int8x16x2_t, int8x16x3_t, int8x16x4_t, int16x4_t,
2218
+ int16x8_t, int32x2_t, int32x4_t, int64x1_t, int64x2_t, poly8x8_t, poly8x8x2_t, poly8x8x3_t,
2219
+ poly8x8x4_t, poly8x16_t, poly8x16x2_t, poly8x16x3_t, poly8x16x4_t, poly16x4_t, poly16x8_t,
2220
+ poly64x1_t, poly64x2_t, uint8x8_t, uint8x8x2_t, uint8x8x3_t, uint8x8x4_t, uint8x16_t,
2221
+ uint8x16x2_t, uint8x16x3_t, uint8x16x4_t, uint16x4_t, uint16x8_t, uint32x2_t, uint32x4_t,
2222
+ uint64x1_t, uint64x2_t
2223
+ ) ;
2224
+ simd_arch_mod ! (
2225
+ #[ cfg( all( feature = "simd-nightly" , target_arch = "arm" ) ) ]
2226
+ arm, arm, int8x4_t, uint8x4_t
2227
+ ) ;
2228
+ } ;
2220
2229
}
2221
2230
2222
2231
/// Safely transmutes a value of one type to a value of another type of the same
@@ -3658,6 +3667,7 @@ unsafe impl<'a> ByteSliceMut for &'a mut [u8] {}
3658
3667
unsafe impl < ' a > ByteSliceMut for RefMut < ' a , [ u8 ] > { }
3659
3668
3660
3669
#[ cfg( feature = "alloc" ) ]
3670
+ #[ cfg_attr( doc_cfg, doc( cfg( feature = "alloc" ) ) ) ]
3661
3671
mod alloc_support {
3662
3672
use alloc:: vec:: Vec ;
3663
3673
@@ -3875,7 +3885,6 @@ mod alloc_support {
3875
3885
}
3876
3886
3877
3887
#[ cfg( feature = "alloc" ) ]
3878
- #[ cfg_attr( doc_cfg, doc( cfg( feature = "alloc" ) ) ) ]
3879
3888
#[ doc( inline) ]
3880
3889
pub use alloc_support:: * ;
3881
3890
0 commit comments