Skip to content

Commit 141342c

Browse files
committed
stabilize lazy_get
1 parent 52fda2e commit 141342c

11 files changed

Lines changed: 58 additions & 75 deletions

library/core/src/cell/lazy.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
165165
/// # Examples
166166
///
167167
/// ```
168-
/// #![feature(lazy_get)]
169168
/// use std::cell::LazyCell;
170169
///
171170
/// let mut lazy = LazyCell::new(|| 92);
@@ -176,7 +175,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
176175
/// assert_eq!(*lazy, 44);
177176
/// ```
178177
#[inline]
179-
#[unstable(feature = "lazy_get", issue = "129333")]
178+
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
180179
pub fn force_mut(this: &mut LazyCell<T, F>) -> &mut T {
181180
#[cold]
182181
/// # Safety
@@ -264,8 +263,6 @@ impl<T, F> LazyCell<T, F> {
264263
/// # Examples
265264
///
266265
/// ```
267-
/// #![feature(lazy_get)]
268-
///
269266
/// use std::cell::LazyCell;
270267
///
271268
/// let mut lazy = LazyCell::new(|| 92);
@@ -276,7 +273,7 @@ impl<T, F> LazyCell<T, F> {
276273
/// assert_eq!(*lazy, 44);
277274
/// ```
278275
#[inline]
279-
#[unstable(feature = "lazy_get", issue = "129333")]
276+
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
280277
pub fn get_mut(this: &mut LazyCell<T, F>) -> Option<&mut T> {
281278
let state = this.state.get_mut();
282279
match state {
@@ -291,8 +288,6 @@ impl<T, F> LazyCell<T, F> {
291288
/// # Examples
292289
///
293290
/// ```
294-
/// #![feature(lazy_get)]
295-
///
296291
/// use std::cell::LazyCell;
297292
///
298293
/// let lazy = LazyCell::new(|| 92);
@@ -302,7 +297,7 @@ impl<T, F> LazyCell<T, F> {
302297
/// assert_eq!(LazyCell::get(&lazy), Some(&92));
303298
/// ```
304299
#[inline]
305-
#[unstable(feature = "lazy_get", issue = "129333")]
300+
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
306301
pub fn get(this: &LazyCell<T, F>) -> Option<&T> {
307302
// SAFETY:
308303
// This is sound for the same reason as in `force`: once the state is

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
#![feature(internal_impls_macro)]
114114
#![feature(ip)]
115115
#![feature(is_ascii_octdigit)]
116-
#![feature(lazy_get)]
117116
#![feature(link_cfg)]
118117
#![feature(offset_of_enum)]
119118
#![feature(panic_internals)]

library/coretests/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
#![feature(iterator_try_collect)]
8080
#![feature(iterator_try_reduce)]
8181
#![feature(layout_for_ptr)]
82-
#![feature(lazy_get)]
8382
#![feature(maybe_uninit_fill)]
8483
#![feature(maybe_uninit_uninit_array_transpose)]
8584
#![feature(min_specialization)]

library/std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@
343343
#![feature(hint_must_use)]
344344
#![feature(int_from_ascii)]
345345
#![feature(ip)]
346-
#![feature(lazy_get)]
347346
#![feature(maybe_uninit_array_assume_init)]
348347
#![feature(panic_can_unwind)]
349348
#![feature(panic_internals)]

library/std/src/sync/lazy_lock.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
172172
/// # Examples
173173
///
174174
/// ```
175-
/// #![feature(lazy_get)]
176175
/// use std::sync::LazyLock;
177176
///
178177
/// let mut lazy = LazyLock::new(|| 92);
@@ -183,7 +182,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
183182
/// assert_eq!(*lazy, 44);
184183
/// ```
185184
#[inline]
186-
#[unstable(feature = "lazy_get", issue = "129333")]
185+
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
187186
pub fn force_mut(this: &mut LazyLock<T, F>) -> &mut T {
188187
#[cold]
189188
/// # Safety
@@ -279,8 +278,6 @@ impl<T, F> LazyLock<T, F> {
279278
/// # Examples
280279
///
281280
/// ```
282-
/// #![feature(lazy_get)]
283-
///
284281
/// use std::sync::LazyLock;
285282
///
286283
/// let mut lazy = LazyLock::new(|| 92);
@@ -291,7 +288,7 @@ impl<T, F> LazyLock<T, F> {
291288
/// assert_eq!(*lazy, 44);
292289
/// ```
293290
#[inline]
294-
#[unstable(feature = "lazy_get", issue = "129333")]
291+
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
295292
pub fn get_mut(this: &mut LazyLock<T, F>) -> Option<&mut T> {
296293
// `state()` does not perform an atomic load, so prefer it over `is_complete()`.
297294
let state = this.once.state();
@@ -309,8 +306,6 @@ impl<T, F> LazyLock<T, F> {
309306
/// # Examples
310307
///
311308
/// ```
312-
/// #![feature(lazy_get)]
313-
///
314309
/// use std::sync::LazyLock;
315310
///
316311
/// let lazy = LazyLock::new(|| 92);
@@ -320,7 +315,7 @@ impl<T, F> LazyLock<T, F> {
320315
/// assert_eq!(LazyLock::get(&lazy), Some(&92));
321316
/// ```
322317
#[inline]
323-
#[unstable(feature = "lazy_get", issue = "129333")]
318+
#[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")]
324319
#[rustc_should_not_be_called_on_const_items]
325320
pub fn get(this: &LazyLock<T, F>) -> Option<&T> {
326321
if this.once.is_completed() {

library/std/tests/sync/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(lazy_get)]
21
#![feature(mapped_lock_guards)]
32
#![feature(mpmc_channel)]
43
#![feature(once_cell_try)]

tests/ui/lint/const-item-interior-mutations-const-cell.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![feature(sync_unsafe_cell)]
55
#![feature(once_cell_try_insert)]
66
#![feature(once_cell_try)]
7-
#![feature(lazy_get)]
87

98
use std::cell::{Cell, RefCell, SyncUnsafeCell, UnsafeCell};
109
use std::cell::{LazyCell, OnceCell};

tests/ui/lint/const-item-interior-mutations-const-cell.stderr

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: mutation of an interior mutable `const` item with call to `force`
2-
--> $DIR/const-item-interior-mutations-const-cell.rs:16:13
2+
--> $DIR/const-item-interior-mutations-const-cell.rs:15:13
33
|
44
LL | let _ = LazyCell::force(&A);
55
| ^^^^^^^^^^^^^^^^^-^
@@ -17,7 +17,7 @@ LL + static A: LazyCell<i32> = LazyCell::new(|| 0);
1717
|
1818

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

359359
warning: mutation of an interior mutable `const` item with call to `get`
360-
--> $DIR/const-item-interior-mutations-const-cell.rs:101:13
360+
--> $DIR/const-item-interior-mutations-const-cell.rs:100:13
361361
|
362362
LL | let _ = A.get();
363363
| -^^^^^^

tests/ui/lint/const-item-interior-mutations-const.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(lock_value_accessors)]
77
#![feature(once_cell_try_insert)]
88
#![feature(once_cell_try)]
9-
#![feature(lazy_get)]
109

1110
use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock};
1211
use std::time::Duration;

tests/ui/lint/const-item-interior-mutations-const.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(lock_value_accessors)]
77
#![feature(once_cell_try_insert)]
88
#![feature(once_cell_try)]
9-
#![feature(lazy_get)]
109

1110
use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock};
1211
use std::time::Duration;

0 commit comments

Comments
 (0)