From 39cb863253a1d7cd8371d49871a20a3244ba6211 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 22 Oct 2021 00:12:00 -0700 Subject: [PATCH] Expose portable-simd as core::simd This enables programmers to use a safe alternative to the current `extern "platform-intrinsics"` API for writing portable SIMD code. This is `#![feature(portable_simd)]` as tracked in #86656 --- library/core/src/lib.rs | 21 +++++++++++++++++++ library/std/src/lib.rs | 4 ++++ rustfmt.toml | 1 + .../issue-71394-no-from-impl.stderr | 3 +++ src/tools/tidy/src/lib.rs | 1 + 5 files changed, 30 insertions(+) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 13b80c05dbb30..b78c7361d9f09 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -386,4 +386,25 @@ pub mod arch { } } +// Pull in the `core_simd` crate directly into libcore. The contents of +// `core_simd` are in a different repository: rust-lang/portable-simd. +// +// `core_simd` depends on libcore, but the contents of this module are +// set up in such a way that directly pulling it here works such that the +// crate uses this crate as its libcore. +#[path = "../../portable-simd/crates/core_simd/src/mod.rs"] +#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)] +#[allow(rustdoc::bare_urls)] +#[unstable(feature = "portable_simd", issue = "86656")] +#[cfg(not(bootstrap))] +mod core_simd; + +#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")] +#[unstable(feature = "portable_simd", issue = "86656")] +#[cfg(not(bootstrap))] +pub mod simd { + #[unstable(feature = "portable_simd", issue = "86656")] + pub use crate::core_simd::simd::*; +} + include!("primitive_docs.rs"); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 1d2d26b8f0046..ea4bcc619fd92 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -320,6 +320,7 @@ #![feature(panic_internals)] #![feature(panic_unwind)] #![feature(pin_static_ref)] +#![cfg_attr(not(bootstrap), feature(portable_simd))] #![feature(prelude_import)] #![feature(ptr_internals)] #![feature(rustc_attrs)] @@ -472,6 +473,9 @@ pub use core::pin; pub use core::ptr; #[stable(feature = "rust1", since = "1.0.0")] pub use core::result; +#[unstable(feature = "portable_simd", issue = "86656")] +#[cfg(not(bootstrap))] +pub use core::simd; #[unstable(feature = "async_stream", issue = "79024")] pub use core::stream; #[stable(feature = "i128", since = "1.26.0")] diff --git a/rustfmt.toml b/rustfmt.toml index 053f3e3ee583b..265f2194fef8d 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -17,6 +17,7 @@ ignore = [ # do not format submodules "library/backtrace", + "library/portable-simd", "library/stdarch", "compiler/rustc_codegen_cranelift", "compiler/rustc_codegen_gcc", diff --git a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr index 355f2038df889..7972437771399 100644 --- a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr @@ -4,6 +4,9 @@ error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | + = help: the following implementations were found: + <[T; LANES] as From>> + <[bool; LANES] as From>> = note: required because of the requirements on the impl of `Into<&[i8]>` for `&[u8]` error: aborting due to previous error diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index a20ea3235ed46..09848462ae207 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -60,6 +60,7 @@ fn filter_dirs(path: &Path) -> bool { "compiler/rustc_codegen_gcc", "src/llvm-project", "library/backtrace", + "library/portable-simd", "library/stdarch", "src/tools/cargo", "src/tools/clippy",