Skip to content
Open
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
11 changes: 3 additions & 8 deletions library/core/src/cell/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
/// # Examples
///
/// ```
/// #![feature(lazy_get)]
/// use std::cell::LazyCell;
///
/// let mut lazy = LazyCell::new(|| 92);
Expand All @@ -176,7 +175,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
/// assert_eq!(*lazy, 44);
/// ```
#[inline]
#[unstable(feature = "lazy_get", issue = "129333")]
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
pub fn force_mut(this: &mut LazyCell<T, F>) -> &mut T {
#[cold]
/// # Safety
Expand Down Expand Up @@ -264,8 +263,6 @@ impl<T, F> LazyCell<T, F> {
/// # Examples
///
/// ```
/// #![feature(lazy_get)]
///
/// use std::cell::LazyCell;
///
/// let mut lazy = LazyCell::new(|| 92);
Expand All @@ -276,7 +273,7 @@ impl<T, F> LazyCell<T, F> {
/// assert_eq!(*lazy, 44);
/// ```
#[inline]
#[unstable(feature = "lazy_get", issue = "129333")]
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
pub fn get_mut(this: &mut LazyCell<T, F>) -> Option<&mut T> {
let state = this.state.get_mut();
match state {
Expand All @@ -291,8 +288,6 @@ impl<T, F> LazyCell<T, F> {
/// # Examples
///
/// ```
/// #![feature(lazy_get)]
///
/// use std::cell::LazyCell;
///
/// let lazy = LazyCell::new(|| 92);
Expand All @@ -302,7 +297,7 @@ impl<T, F> LazyCell<T, F> {
/// assert_eq!(LazyCell::get(&lazy), Some(&92));
/// ```
#[inline]
#[unstable(feature = "lazy_get", issue = "129333")]
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
pub fn get(this: &LazyCell<T, F>) -> Option<&T> {
// SAFETY:
// This is sound for the same reason as in `force`: once the state is
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
#![feature(internal_impls_macro)]
#![feature(ip)]
#![feature(is_ascii_octdigit)]
#![feature(lazy_get)]
#![feature(link_cfg)]
#![feature(offset_of_enum)]
#![feature(panic_internals)]
Expand Down
1 change: 0 additions & 1 deletion library/coretests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
#![feature(iterator_try_collect)]
#![feature(iterator_try_reduce)]
#![feature(layout_for_ptr)]
#![feature(lazy_get)]
#![feature(maybe_uninit_fill)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(min_specialization)]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@
#![feature(hint_must_use)]
#![feature(int_from_ascii)]
#![feature(ip)]
#![feature(lazy_get)]
#![feature(maybe_uninit_array_assume_init)]
#![feature(panic_can_unwind)]
#![feature(panic_internals)]
Expand Down
11 changes: 3 additions & 8 deletions library/std/src/sync/lazy_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
/// # Examples
///
/// ```
/// #![feature(lazy_get)]
/// use std::sync::LazyLock;
///
/// let mut lazy = LazyLock::new(|| 92);
Expand All @@ -183,7 +182,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
/// assert_eq!(*lazy, 44);
/// ```
#[inline]
#[unstable(feature = "lazy_get", issue = "129333")]
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
pub fn force_mut(this: &mut LazyLock<T, F>) -> &mut T {
#[cold]
/// # Safety
Expand Down Expand Up @@ -279,8 +278,6 @@ impl<T, F> LazyLock<T, F> {
/// # Examples
///
/// ```
/// #![feature(lazy_get)]
///
/// use std::sync::LazyLock;
///
/// let mut lazy = LazyLock::new(|| 92);
Expand All @@ -291,7 +288,7 @@ impl<T, F> LazyLock<T, F> {
/// assert_eq!(*lazy, 44);
/// ```
#[inline]
#[unstable(feature = "lazy_get", issue = "129333")]
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
pub fn get_mut(this: &mut LazyLock<T, F>) -> Option<&mut T> {
// `state()` does not perform an atomic load, so prefer it over `is_complete()`.
let state = this.once.state();
Expand All @@ -309,8 +306,6 @@ impl<T, F> LazyLock<T, F> {
/// # Examples
///
/// ```
/// #![feature(lazy_get)]
///
/// use std::sync::LazyLock;
///
/// let lazy = LazyLock::new(|| 92);
Expand All @@ -320,7 +315,7 @@ impl<T, F> LazyLock<T, F> {
/// assert_eq!(LazyLock::get(&lazy), Some(&92));
/// ```
#[inline]
#[unstable(feature = "lazy_get", issue = "129333")]
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
#[rustc_should_not_be_called_on_const_items]
pub fn get(this: &LazyLock<T, F>) -> Option<&T> {
if this.once.is_completed() {
Expand Down
1 change: 0 additions & 1 deletion library/std/tests/sync/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(lazy_get)]
#![feature(mapped_lock_guards)]
#![feature(mpmc_channel)]
#![feature(once_cell_try)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/lint/const-item-interior-mutations-const-cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#![feature(sync_unsafe_cell)]
#![feature(once_cell_try_insert)]
#![feature(once_cell_try)]
#![feature(lazy_get)]

use std::cell::{Cell, RefCell, SyncUnsafeCell, UnsafeCell};
use std::cell::{LazyCell, OnceCell};
Expand Down
44 changes: 22 additions & 22 deletions tests/ui/lint/const-item-interior-mutations-const-cell.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: mutation of an interior mutable `const` item with call to `force`
--> $DIR/const-item-interior-mutations-const-cell.rs:16:13
--> $DIR/const-item-interior-mutations-const-cell.rs:15:13
|
LL | let _ = LazyCell::force(&A);
| ^^^^^^^^^^^^^^^^^-^
Expand All @@ -17,7 +17,7 @@ LL + static A: LazyCell<i32> = LazyCell::new(|| 0);
|

warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const-cell.rs:23:13
--> $DIR/const-item-interior-mutations-const-cell.rs:22:13
|
LL | let _ = A.set(10);
| -^^^^^^^^
Expand All @@ -34,7 +34,7 @@ LL + static A: OnceCell<i32> = OnceCell::new();
|

warning: mutation of an interior mutable `const` item with call to `try_insert`
--> $DIR/const-item-interior-mutations-const-cell.rs:26:13
--> $DIR/const-item-interior-mutations-const-cell.rs:25:13
|
LL | let _ = A.try_insert(20);
| -^^^^^^^^^^^^^^^
Expand All @@ -51,7 +51,7 @@ LL + static A: OnceCell<i32> = OnceCell::new();
|

warning: mutation of an interior mutable `const` item with call to `get_or_init`
--> $DIR/const-item-interior-mutations-const-cell.rs:29:13
--> $DIR/const-item-interior-mutations-const-cell.rs:28:13
|
LL | let _ = A.get_or_init(|| 30);
| -^^^^^^^^^^^^^^^^^^^
Expand All @@ -68,7 +68,7 @@ LL + static A: OnceCell<i32> = OnceCell::new();
|

warning: mutation of an interior mutable `const` item with call to `get_or_try_init`
--> $DIR/const-item-interior-mutations-const-cell.rs:32:13
--> $DIR/const-item-interior-mutations-const-cell.rs:31:13
|
LL | let _ = A.get_or_try_init(|| Ok::<_, ()>(40));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -85,7 +85,7 @@ LL + static A: OnceCell<i32> = OnceCell::new();
|

warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const-cell.rs:39:13
--> $DIR/const-item-interior-mutations-const-cell.rs:38:13
|
LL | let _ = A.set(1);
| -^^^^^^^
Expand All @@ -102,7 +102,7 @@ LL + static A: Cell<i32> = Cell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-cell.rs:42:13
--> $DIR/const-item-interior-mutations-const-cell.rs:41:13
|
LL | let _ = A.swap(&A);
| -^^^^^^^^^
Expand All @@ -119,7 +119,7 @@ LL + static A: Cell<i32> = Cell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const-cell.rs:45:13
--> $DIR/const-item-interior-mutations-const-cell.rs:44:13
|
LL | let _ = A.replace(2);
| -^^^^^^^^^^^
Expand All @@ -136,7 +136,7 @@ LL + static A: Cell<i32> = Cell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const-cell.rs:48:13
--> $DIR/const-item-interior-mutations-const-cell.rs:47:13
|
LL | let _ = A.get();
| -^^^^^^
Expand All @@ -153,7 +153,7 @@ LL + static A: Cell<i32> = Cell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `update`
--> $DIR/const-item-interior-mutations-const-cell.rs:51:13
--> $DIR/const-item-interior-mutations-const-cell.rs:50:13
|
LL | let _ = A.update(|x| x + 1);
| -^^^^^^^^^^^^^^^^^^
Expand All @@ -170,7 +170,7 @@ LL + static A: Cell<i32> = Cell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const-cell.rs:58:13
--> $DIR/const-item-interior-mutations-const-cell.rs:57:13
|
LL | let _ = A.replace(1);
| -^^^^^^^^^^^
Expand All @@ -187,7 +187,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `replace_with`
--> $DIR/const-item-interior-mutations-const-cell.rs:61:13
--> $DIR/const-item-interior-mutations-const-cell.rs:60:13
|
LL | let _ = A.replace_with(|x| *x + 2);
| -^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -204,7 +204,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-cell.rs:64:13
--> $DIR/const-item-interior-mutations-const-cell.rs:63:13
|
LL | let _ = A.swap(&A);
| -^^^^^^^^^
Expand All @@ -221,7 +221,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `borrow`
--> $DIR/const-item-interior-mutations-const-cell.rs:67:13
--> $DIR/const-item-interior-mutations-const-cell.rs:66:13
|
LL | let _ = A.borrow();
| -^^^^^^^^^
Expand All @@ -238,7 +238,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `try_borrow`
--> $DIR/const-item-interior-mutations-const-cell.rs:70:13
--> $DIR/const-item-interior-mutations-const-cell.rs:69:13
|
LL | let _ = A.try_borrow();
| -^^^^^^^^^^^^^
Expand All @@ -255,7 +255,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `borrow_mut`
--> $DIR/const-item-interior-mutations-const-cell.rs:73:13
--> $DIR/const-item-interior-mutations-const-cell.rs:72:13
|
LL | let _ = A.borrow_mut();
| -^^^^^^^^^^^^^
Expand All @@ -272,7 +272,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `try_borrow_mut`
--> $DIR/const-item-interior-mutations-const-cell.rs:76:13
--> $DIR/const-item-interior-mutations-const-cell.rs:75:13
|
LL | let _ = A.try_borrow_mut();
| -^^^^^^^^^^^^^^^^^
Expand All @@ -289,7 +289,7 @@ LL + static A: RefCell<i32> = RefCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const-cell.rs:83:22
--> $DIR/const-item-interior-mutations-const-cell.rs:82:22
|
LL | let _ = unsafe { A.replace(1) };
| -^^^^^^^^^^^
Expand All @@ -306,7 +306,7 @@ LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const-cell.rs:86:13
--> $DIR/const-item-interior-mutations-const-cell.rs:85:13
|
LL | let _ = A.get();
| -^^^^^^
Expand All @@ -323,7 +323,7 @@ LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `as_ref_unchecked`
--> $DIR/const-item-interior-mutations-const-cell.rs:90:17
--> $DIR/const-item-interior-mutations-const-cell.rs:89:17
|
LL | let _ = A.as_ref_unchecked();
| -^^^^^^^^^^^^^^^^^^^
Expand All @@ -340,7 +340,7 @@ LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `as_mut_unchecked`
--> $DIR/const-item-interior-mutations-const-cell.rs:93:17
--> $DIR/const-item-interior-mutations-const-cell.rs:92:17
|
LL | let _ = A.as_mut_unchecked();
| -^^^^^^^^^^^^^^^^^^^
Expand All @@ -357,7 +357,7 @@ LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|

warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const-cell.rs:101:13
--> $DIR/const-item-interior-mutations-const-cell.rs:100:13
|
LL | let _ = A.get();
| -^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/lint/const-item-interior-mutations-const.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![feature(lock_value_accessors)]
#![feature(once_cell_try_insert)]
#![feature(once_cell_try)]
#![feature(lazy_get)]

use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock};
use std::time::Duration;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/lint/const-item-interior-mutations-const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![feature(lock_value_accessors)]
#![feature(once_cell_try_insert)]
#![feature(once_cell_try)]
#![feature(lazy_get)]

use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock};
use std::time::Duration;
Expand Down
Loading
Loading