Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ impl AtomicBool {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bool = true;
Expand All @@ -618,7 +617,7 @@ impl AtomicBool {
/// ```
#[inline]
#[cfg(target_has_atomic_primitive_alignment = "8")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn from_mut(v: &mut bool) -> &mut Self {
// SAFETY: the mutable reference guarantees unique ownership, and
// alignment of both `bool` and `Self` is 1.
Expand All @@ -633,7 +632,6 @@ impl AtomicBool {
/// # Examples
///
/// ```ignore-wasm
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bools = [const { AtomicBool::new(false) }; 10];
Expand All @@ -653,7 +651,7 @@ impl AtomicBool {
/// });
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn get_mut_slice(this: &mut [Self]) -> &mut [bool] {
// SAFETY: the mutable reference guarantees unique ownership.
unsafe { &mut *(this as *mut [Self] as *mut [bool]) }
Expand All @@ -664,7 +662,6 @@ impl AtomicBool {
/// # Examples
///
/// ```rust,ignore-wasm
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bools = [false; 10];
Expand All @@ -678,7 +675,7 @@ impl AtomicBool {
/// ```
#[inline]
#[cfg(target_has_atomic_primitive_alignment = "8")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn from_mut_slice(v: &mut [bool]) -> &mut [Self] {
// SAFETY: the mutable reference guarantees unique ownership, and
// alignment of both `bool` and `Self` is 1.
Expand Down Expand Up @@ -1577,7 +1574,6 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
/// let mut data = 123;
Expand All @@ -1589,7 +1585,7 @@ impl<T> AtomicPtr<T> {
/// ```
#[inline]
#[cfg(target_has_atomic_primitive_alignment = "ptr")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn from_mut(v: &mut *mut T) -> &mut Self {
let [] = [(); align_of::<AtomicPtr<()>>() - align_of::<*mut ()>()];
// SAFETY:
Expand All @@ -1607,7 +1603,6 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```ignore-wasm
/// #![feature(atomic_from_mut)]
/// use std::ptr::null_mut;
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
Expand All @@ -1633,7 +1628,7 @@ impl<T> AtomicPtr<T> {
/// });
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn get_mut_slice(this: &mut [Self]) -> &mut [*mut T] {
// SAFETY: the mutable reference guarantees unique ownership.
unsafe { &mut *(this as *mut [Self] as *mut [*mut T]) }
Expand All @@ -1646,7 +1641,6 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```ignore-wasm
/// #![feature(atomic_from_mut)]
/// use std::ptr::null_mut;
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
Expand All @@ -1668,7 +1662,7 @@ impl<T> AtomicPtr<T> {
/// ```
#[inline]
#[cfg(target_has_atomic_primitive_alignment = "ptr")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn from_mut_slice(v: &mut [*mut T]) -> &mut [Self] {
// SAFETY:
// - the mutable reference guarantees unique ownership.
Expand Down Expand Up @@ -2721,7 +2715,6 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
///
/// let mut some_int = 123;
Expand All @@ -2732,7 +2725,7 @@ macro_rules! atomic_int {
///
#[inline]
#[$cfg_align]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn from_mut(v: &mut $int_type) -> &mut Self {
let [] = [(); align_of::<Self>() - align_of::<$int_type>()];
// SAFETY:
Expand All @@ -2750,7 +2743,6 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```ignore-wasm
/// #![feature(atomic_from_mut)]
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
///
#[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")]
Expand All @@ -2772,7 +2764,7 @@ macro_rules! atomic_int {
/// });
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn get_mut_slice(this: &mut [Self]) -> &mut [$int_type] {
// SAFETY: the mutable reference guarantees unique ownership.
unsafe { &mut *(this as *mut [Self] as *mut [$int_type]) }
Expand All @@ -2791,7 +2783,6 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```ignore-wasm
/// #![feature(atomic_from_mut)]
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
///
/// let mut some_ints = [0; 10];
Expand All @@ -2807,7 +2798,7 @@ macro_rules! atomic_int {
/// ```
#[inline]
#[$cfg_align]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
pub fn from_mut_slice(v: &mut [$int_type]) -> &mut [Self] {
let [] = [(); align_of::<Self>() - align_of::<$int_type>()];
// SAFETY:
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/tests/pass/0weak_memory/extra_cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Tests operations not performable through C++'s atomic API
// but doable in safe (at least sound) Rust.

#![feature(atomic_from_mut)]

use std::sync::atomic::Ordering::*;
use std::sync::atomic::{AtomicU16, AtomicU32};
use std::thread::spawn;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0599]: no associated function or constant named `from_mut` found for struct `Atomic<u64>` in the current scope
--> $DIR/atomic-from-mut-not-available.rs:24:36
--> $DIR/atomic-from-mut-not-available.rs:25:36
|
LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
| ^^^^^^^^ associated function or constant not found in `Atomic<u64>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// ... but pass on 64-bit x86_64 linux.
//@[alignment_matches] only-x86_64
//@[alignment_matches] only-linux
//@[alignment_matches] check-pass

fn main() {
core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
//[alignment_mismatch]~^ ERROR no associated function or constant named `from_mut` found for struct `Atomic<u64>`
//[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut`
}
Loading