Skip to content

Commit

Permalink
Expose portable-simd as core::simd
Browse files Browse the repository at this point in the history
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 rust-lang#86656
  • Loading branch information
workingjubilee committed Nov 13, 2021
1 parent fdee059 commit 39cb863
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
4 changes: 4 additions & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ignore = [

# do not format submodules
"library/backtrace",
"library/portable-simd",
"library/stdarch",
"compiler/rustc_codegen_cranelift",
"compiler/rustc_codegen_gcc",
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/suggestions/issue-71394-no-from-impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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<Simd<T, LANES>>>
<[bool; LANES] as From<Mask<T, LANES>>>
= note: required because of the requirements on the impl of `Into<&[i8]>` for `&[u8]`

error: aborting due to previous error
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 39cb863

Please sign in to comment.