Skip to content

Commit d18120f

Browse files
Rollup merge of #158573 - WaffleLapkin:stabilize_atomic_from_mut, r=clarfonthey
stabilize `feature(atomic_from_mut)` Completed FCP: #76314 (comment) Closes #76314
2 parents 7a2a130 + 75616f6 commit d18120f

5 files changed

Lines changed: 11 additions & 35 deletions

File tree

library/core/src/sync/atomic.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,6 @@ impl AtomicBool {
608608
/// # Examples
609609
///
610610
/// ```
611-
/// #![feature(atomic_from_mut)]
612611
/// use std::sync::atomic::{AtomicBool, Ordering};
613612
///
614613
/// let mut some_bool = true;
@@ -618,7 +617,7 @@ impl AtomicBool {
618617
/// ```
619618
#[inline]
620619
#[cfg(target_has_atomic_primitive_alignment = "8")]
621-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
620+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
622621
pub fn from_mut(v: &mut bool) -> &mut Self {
623622
// SAFETY: the mutable reference guarantees unique ownership, and
624623
// alignment of both `bool` and `Self` is 1.
@@ -633,7 +632,6 @@ impl AtomicBool {
633632
/// # Examples
634633
///
635634
/// ```ignore-wasm
636-
/// #![feature(atomic_from_mut)]
637635
/// use std::sync::atomic::{AtomicBool, Ordering};
638636
///
639637
/// let mut some_bools = [const { AtomicBool::new(false) }; 10];
@@ -653,7 +651,7 @@ impl AtomicBool {
653651
/// });
654652
/// ```
655653
#[inline]
656-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
654+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
657655
pub fn get_mut_slice(this: &mut [Self]) -> &mut [bool] {
658656
// SAFETY: the mutable reference guarantees unique ownership.
659657
unsafe { &mut *(this as *mut [Self] as *mut [bool]) }
@@ -664,7 +662,6 @@ impl AtomicBool {
664662
/// # Examples
665663
///
666664
/// ```rust,ignore-wasm
667-
/// #![feature(atomic_from_mut)]
668665
/// use std::sync::atomic::{AtomicBool, Ordering};
669666
///
670667
/// let mut some_bools = [false; 10];
@@ -678,7 +675,7 @@ impl AtomicBool {
678675
/// ```
679676
#[inline]
680677
#[cfg(target_has_atomic_primitive_alignment = "8")]
681-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
678+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
682679
pub fn from_mut_slice(v: &mut [bool]) -> &mut [Self] {
683680
// SAFETY: the mutable reference guarantees unique ownership, and
684681
// alignment of both `bool` and `Self` is 1.
@@ -1577,7 +1574,6 @@ impl<T> AtomicPtr<T> {
15771574
/// # Examples
15781575
///
15791576
/// ```
1580-
/// #![feature(atomic_from_mut)]
15811577
/// use std::sync::atomic::{AtomicPtr, Ordering};
15821578
///
15831579
/// let mut data = 123;
@@ -1589,7 +1585,7 @@ impl<T> AtomicPtr<T> {
15891585
/// ```
15901586
#[inline]
15911587
#[cfg(target_has_atomic_primitive_alignment = "ptr")]
1592-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
1588+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
15931589
pub fn from_mut(v: &mut *mut T) -> &mut Self {
15941590
let [] = [(); align_of::<AtomicPtr<()>>() - align_of::<*mut ()>()];
15951591
// SAFETY:
@@ -1607,7 +1603,6 @@ impl<T> AtomicPtr<T> {
16071603
/// # Examples
16081604
///
16091605
/// ```ignore-wasm
1610-
/// #![feature(atomic_from_mut)]
16111606
/// use std::ptr::null_mut;
16121607
/// use std::sync::atomic::{AtomicPtr, Ordering};
16131608
///
@@ -1633,7 +1628,7 @@ impl<T> AtomicPtr<T> {
16331628
/// });
16341629
/// ```
16351630
#[inline]
1636-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
1631+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
16371632
pub fn get_mut_slice(this: &mut [Self]) -> &mut [*mut T] {
16381633
// SAFETY: the mutable reference guarantees unique ownership.
16391634
unsafe { &mut *(this as *mut [Self] as *mut [*mut T]) }
@@ -1646,7 +1641,6 @@ impl<T> AtomicPtr<T> {
16461641
/// # Examples
16471642
///
16481643
/// ```ignore-wasm
1649-
/// #![feature(atomic_from_mut)]
16501644
/// use std::ptr::null_mut;
16511645
/// use std::sync::atomic::{AtomicPtr, Ordering};
16521646
///
@@ -1668,7 +1662,7 @@ impl<T> AtomicPtr<T> {
16681662
/// ```
16691663
#[inline]
16701664
#[cfg(target_has_atomic_primitive_alignment = "ptr")]
1671-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
1665+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
16721666
pub fn from_mut_slice(v: &mut [*mut T]) -> &mut [Self] {
16731667
// SAFETY:
16741668
// - the mutable reference guarantees unique ownership.
@@ -2721,7 +2715,6 @@ macro_rules! atomic_int {
27212715
/// # Examples
27222716
///
27232717
/// ```
2724-
/// #![feature(atomic_from_mut)]
27252718
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
27262719
///
27272720
/// let mut some_int = 123;
@@ -2732,7 +2725,7 @@ macro_rules! atomic_int {
27322725
///
27332726
#[inline]
27342727
#[$cfg_align]
2735-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
2728+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
27362729
pub fn from_mut(v: &mut $int_type) -> &mut Self {
27372730
let [] = [(); align_of::<Self>() - align_of::<$int_type>()];
27382731
// SAFETY:
@@ -2750,7 +2743,6 @@ macro_rules! atomic_int {
27502743
/// # Examples
27512744
///
27522745
/// ```ignore-wasm
2753-
/// #![feature(atomic_from_mut)]
27542746
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
27552747
///
27562748
#[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")]
@@ -2772,7 +2764,7 @@ macro_rules! atomic_int {
27722764
/// });
27732765
/// ```
27742766
#[inline]
2775-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
2767+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
27762768
pub fn get_mut_slice(this: &mut [Self]) -> &mut [$int_type] {
27772769
// SAFETY: the mutable reference guarantees unique ownership.
27782770
unsafe { &mut *(this as *mut [Self] as *mut [$int_type]) }
@@ -2791,7 +2783,6 @@ macro_rules! atomic_int {
27912783
/// # Examples
27922784
///
27932785
/// ```ignore-wasm
2794-
/// #![feature(atomic_from_mut)]
27952786
#[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")]
27962787
///
27972788
/// let mut some_ints = [0; 10];
@@ -2807,7 +2798,7 @@ macro_rules! atomic_int {
28072798
/// ```
28082799
#[inline]
28092800
#[$cfg_align]
2810-
#[unstable(feature = "atomic_from_mut", issue = "76314")]
2801+
#[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")]
28112802
pub fn from_mut_slice(v: &mut [$int_type]) -> &mut [Self] {
28122803
let [] = [(); align_of::<Self>() - align_of::<$int_type>()];
28132804
// SAFETY:

src/tools/miri/tests/pass/0weak_memory/extra_cpp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Tests operations not performable through C++'s atomic API
44
// but doable in safe (at least sound) Rust.
55

6-
#![feature(atomic_from_mut)]
7-
86
use std::sync::atomic::Ordering::*;
97
use std::sync::atomic::{AtomicU16, AtomicU32};
108
use std::thread::spawn;

tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_matches.stderr

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0599]: no associated function or constant named `from_mut` found for struct `Atomic<u64>` in the current scope
2-
--> $DIR/atomic-from-mut-not-available.rs:24:36
2+
--> $DIR/atomic-from-mut-not-available.rs:25:36
33
|
44
LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
55
| ^^^^^^^^ associated function or constant not found in `Atomic<u64>`

tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
// ... but pass on 64-bit x86_64 linux.
2020
//@[alignment_matches] only-x86_64
2121
//@[alignment_matches] only-linux
22+
//@[alignment_matches] check-pass
2223

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

0 commit comments

Comments
 (0)