Skip to content

Commit 11bbbe5

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 rust-lang#86656
1 parent 3ba8ad5 commit 11bbbe5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

core/src/lib.rs

Lines changed: 21 additions & 0 deletions
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");

std/src/lib.rs

Lines changed: 4 additions & 0 deletions
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")]

0 commit comments

Comments
 (0)