Skip to content

Commit 79ad512

Browse files
committed
warn against using intrinsics that leave the scope of our memory model
1 parent 85c42b7 commit 79ad512

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/core/src/intrinsics.rs

+10
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ extern "rust-intrinsic" {
341341
/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`].
342342
#[rustc_nounwind]
343343
pub fn atomic_load_relaxed<T: Copy>(src: *const T) -> T;
344+
/// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model!
345+
/// In terms of the Rust Abstract Machine, this operation is equivalent to `src.read()`,
346+
/// i.e., it performs a non-atomic read.
344347
#[rustc_nounwind]
345348
pub fn atomic_load_unordered<T: Copy>(src: *const T) -> T;
346349

@@ -365,6 +368,9 @@ extern "rust-intrinsic" {
365368
/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::store`].
366369
#[rustc_nounwind]
367370
pub fn atomic_store_relaxed<T: Copy>(dst: *mut T, val: T);
371+
/// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model!
372+
/// In terms of the Rust Abstract Machine, this operation is equivalent to `dst.write(val)`,
373+
/// i.e., it performs a non-atomic write.
368374
#[rustc_nounwind]
369375
pub fn atomic_store_unordered<T: Copy>(dst: *mut T, val: T);
370376

@@ -2312,6 +2318,10 @@ extern "rust-intrinsic" {
23122318

23132319
/// Emits a `!nontemporal` store according to LLVM (see their docs).
23142320
/// Probably will never become stable.
2321+
///
2322+
/// Do NOT use this intrinsic; "nontemporal" operations do not exist in our memory model!
2323+
/// It exists to support current stdarch, but the plan is to change stdarch and remove this intrinsic.
2324+
/// See <https://github.com/rust-lang/rust/issues/114582> for some more discussion.
23152325
#[rustc_nounwind]
23162326
pub fn nontemporal_store<T>(ptr: *mut T, val: T);
23172327

0 commit comments

Comments
 (0)