Skip to content

Commit 329753e

Browse files
authored
Rollup merge of rust-lang#93414 - Amanieu:std_arch_detect, r=m-ou-se
Move unstable is_{arch}_feature_detected! macros to std::arch These macros are unstable, except for `is_x86_feature_detected` which is still exported from the crate root for backwards-compatibility. This should unblock the stabilization of `is_aarch64_feature_detected`. r? ```@m-ou-se```
2 parents 0b2359b + 9a814b8 commit 329753e

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

library/std/src/lib.rs

+25-19
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,6 @@ pub use alloc_crate::string;
403403
pub use alloc_crate::vec;
404404
#[stable(feature = "rust1", since = "1.0.0")]
405405
pub use core::any;
406-
#[stable(feature = "simd_arch", since = "1.27.0")]
407-
// The `no_inline`-attribute is required to make the documentation of all
408-
// targets available.
409-
// See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
410-
// more information.
411-
#[doc(no_inline)] // Note (#82861): required for correct documentation
412-
pub use core::arch;
413406
#[stable(feature = "core_array", since = "1.36.0")]
414407
pub use core::array;
415408
#[stable(feature = "rust1", since = "1.0.0")]
@@ -527,6 +520,31 @@ pub mod task {
527520
pub use alloc::task::*;
528521
}
529522

523+
#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
524+
#[stable(feature = "simd_arch", since = "1.27.0")]
525+
pub mod arch {
526+
#[stable(feature = "simd_arch", since = "1.27.0")]
527+
// The `no_inline`-attribute is required to make the documentation of all
528+
// targets available.
529+
// See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
530+
// more information.
531+
#[doc(no_inline)] // Note (#82861): required for correct documentation
532+
pub use core::arch::*;
533+
534+
#[stable(feature = "simd_x86", since = "1.27.0")]
535+
pub use std_detect::is_x86_feature_detected;
536+
#[unstable(feature = "stdsimd", issue = "48556")]
537+
pub use std_detect::{
538+
is_aarch64_feature_detected, is_arm_feature_detected, is_mips64_feature_detected,
539+
is_mips_feature_detected, is_powerpc64_feature_detected, is_powerpc_feature_detected,
540+
is_riscv_feature_detected,
541+
};
542+
}
543+
544+
// This was stabilized in the crate root so we have to keep it there.
545+
#[stable(feature = "simd_x86", since = "1.27.0")]
546+
pub use std_detect::is_x86_feature_detected;
547+
530548
// The runtime entry point and a few unstable public functions used by the
531549
// compiler
532550
#[macro_use]
@@ -545,18 +563,6 @@ mod panicking;
545563
#[allow(dead_code, unused_attributes)]
546564
mod backtrace_rs;
547565

548-
#[stable(feature = "simd_x86", since = "1.27.0")]
549-
pub use std_detect::is_x86_feature_detected;
550-
#[doc(hidden)]
551-
#[unstable(feature = "stdsimd", issue = "48556")]
552-
pub use std_detect::*;
553-
#[unstable(feature = "stdsimd", issue = "48556")]
554-
pub use std_detect::{
555-
is_aarch64_feature_detected, is_arm_feature_detected, is_mips64_feature_detected,
556-
is_mips_feature_detected, is_powerpc64_feature_detected, is_powerpc_feature_detected,
557-
is_riscv_feature_detected,
558-
};
559-
560566
// Re-export macros defined in libcore.
561567
#[stable(feature = "rust1", since = "1.0.0")]
562568
#[allow(deprecated, deprecated_in_future)]

library/std/tests/run-time-detect.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[test]
1515
#[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))]
1616
fn arm_linux() {
17+
use std::arch::is_arm_feature_detected;
1718
println!("neon: {}", is_arm_feature_detected!("neon"));
1819
println!("pmull: {}", is_arm_feature_detected!("pmull"));
1920
println!("crypto: {}", is_arm_feature_detected!("crypto"));
@@ -25,6 +26,7 @@ fn arm_linux() {
2526
#[test]
2627
#[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))]
2728
fn aarch64_linux() {
29+
use std::arch::is_aarch64_feature_detected;
2830
println!("neon: {}", is_aarch64_feature_detected!("neon"));
2931
println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
3032
println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
@@ -71,6 +73,7 @@ fn aarch64_linux() {
7173
#[test]
7274
#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
7375
fn powerpc_linux() {
76+
use std::arch::is_powerpc_feature_detected;
7477
println!("altivec: {}", is_powerpc_feature_detected!("altivec"));
7578
println!("vsx: {}", is_powerpc_feature_detected!("vsx"));
7679
println!("power8: {}", is_powerpc_feature_detected!("power8"));
@@ -79,6 +82,7 @@ fn powerpc_linux() {
7982
#[test]
8083
#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
8184
fn powerpc64_linux() {
85+
use std::arch::is_powerpc64_feature_detected;
8286
println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
8387
println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
8488
println!("power8: {}", is_powerpc64_feature_detected!("power8"));
@@ -87,6 +91,8 @@ fn powerpc64_linux() {
8791
#[test]
8892
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
8993
fn x86_all() {
94+
use std::arch::is_x86_feature_detected;
95+
9096
// the below is the set of features we can test at runtime, but don't actually
9197
// use to gate anything and are thus not part of the X86_ALLOWED_FEATURES list
9298

0 commit comments

Comments
 (0)