Skip to content

Commit 39cb863

Browse files
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
1 parent fdee059 commit 39cb863

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

library/core/src/lib.rs

+21
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,25 @@ pub mod arch {
386386
}
387387
}
388388

389+
// Pull in the `core_simd` crate directly into libcore. The contents of
390+
// `core_simd` are in a different repository: rust-lang/portable-simd.
391+
//
392+
// `core_simd` depends on libcore, but the contents of this module are
393+
// set up in such a way that directly pulling it here works such that the
394+
// crate uses this crate as its libcore.
395+
#[path = "../../portable-simd/crates/core_simd/src/mod.rs"]
396+
#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
397+
#[allow(rustdoc::bare_urls)]
398+
#[unstable(feature = "portable_simd", issue = "86656")]
399+
#[cfg(not(bootstrap))]
400+
mod core_simd;
401+
402+
#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
403+
#[unstable(feature = "portable_simd", issue = "86656")]
404+
#[cfg(not(bootstrap))]
405+
pub mod simd {
406+
#[unstable(feature = "portable_simd", issue = "86656")]
407+
pub use crate::core_simd::simd::*;
408+
}
409+
389410
include!("primitive_docs.rs");

library/std/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
#![feature(panic_internals)]
321321
#![feature(panic_unwind)]
322322
#![feature(pin_static_ref)]
323+
#![cfg_attr(not(bootstrap), feature(portable_simd))]
323324
#![feature(prelude_import)]
324325
#![feature(ptr_internals)]
325326
#![feature(rustc_attrs)]
@@ -472,6 +473,9 @@ pub use core::pin;
472473
pub use core::ptr;
473474
#[stable(feature = "rust1", since = "1.0.0")]
474475
pub use core::result;
476+
#[unstable(feature = "portable_simd", issue = "86656")]
477+
#[cfg(not(bootstrap))]
478+
pub use core::simd;
475479
#[unstable(feature = "async_stream", issue = "79024")]
476480
pub use core::stream;
477481
#[stable(feature = "i128", since = "1.26.0")]

rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ignore = [
1717

1818
# do not format submodules
1919
"library/backtrace",
20+
"library/portable-simd",
2021
"library/stdarch",
2122
"compiler/rustc_codegen_cranelift",
2223
"compiler/rustc_codegen_gcc",

src/test/ui/suggestions/issue-71394-no-from-impl.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied
44
LL | let _: &[i8] = data.into();
55
| ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]`
66
|
7+
= help: the following implementations were found:
8+
<[T; LANES] as From<Simd<T, LANES>>>
9+
<[bool; LANES] as From<Mask<T, LANES>>>
710
= note: required because of the requirements on the impl of `Into<&[i8]>` for `&[u8]`
811

912
error: aborting due to previous error

src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ fn filter_dirs(path: &Path) -> bool {
6060
"compiler/rustc_codegen_gcc",
6161
"src/llvm-project",
6262
"library/backtrace",
63+
"library/portable-simd",
6364
"library/stdarch",
6465
"src/tools/cargo",
6566
"src/tools/clippy",

0 commit comments

Comments
 (0)