Skip to content

Commit 6c5f53e

Browse files
committed
Stabilize const-calling existing const-fns in std
Fixes #46038
1 parent 827cb0d commit 6c5f53e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+8
-164
lines changed

src/libcore/cell.rs

-3
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ impl<T> Cell<T> {
329329
/// let c = Cell::new(5);
330330
/// ```
331331
#[stable(feature = "rust1", since = "1.0.0")]
332-
#[rustc_const_unstable(feature = "const_cell_new")]
333332
#[inline]
334333
pub const fn new(value: T) -> Cell<T> {
335334
Cell {
@@ -544,7 +543,6 @@ impl<T> RefCell<T> {
544543
/// let c = RefCell::new(5);
545544
/// ```
546545
#[stable(feature = "rust1", since = "1.0.0")]
547-
#[rustc_const_unstable(feature = "const_refcell_new")]
548546
#[inline]
549547
pub const fn new(value: T) -> RefCell<T> {
550548
RefCell {
@@ -1215,7 +1213,6 @@ impl<T> UnsafeCell<T> {
12151213
/// let uc = UnsafeCell::new(5);
12161214
/// ```
12171215
#[stable(feature = "rust1", since = "1.0.0")]
1218-
#[rustc_const_unstable(feature = "const_unsafe_cell_new")]
12191216
#[inline]
12201217
pub const fn new(value: T) -> UnsafeCell<T> {
12211218
UnsafeCell { value: value }

src/libcore/lib.rs

-34
Original file line numberDiff line numberDiff line change
@@ -85,47 +85,13 @@
8585
#![feature(prelude_import)]
8686
#![feature(repr_simd, platform_intrinsics)]
8787
#![feature(rustc_attrs)]
88-
#![feature(rustc_const_unstable)]
8988
#![feature(specialization)]
9089
#![feature(staged_api)]
9190
#![feature(unboxed_closures)]
9291
#![feature(untagged_unions)]
9392
#![feature(unwind_attributes)]
94-
#![feature(const_min_value)]
95-
#![feature(const_max_value)]
96-
#![feature(const_atomic_bool_new)]
97-
#![feature(const_atomic_isize_new)]
98-
#![feature(const_atomic_usize_new)]
99-
#![feature(const_atomic_i8_new)]
100-
#![feature(const_atomic_u8_new)]
101-
#![feature(const_atomic_i16_new)]
102-
#![feature(const_atomic_u16_new)]
103-
#![feature(const_atomic_i32_new)]
104-
#![feature(const_atomic_u32_new)]
105-
#![feature(const_atomic_i64_new)]
106-
#![feature(const_atomic_u64_new)]
107-
#![feature(const_unsafe_cell_new)]
108-
#![feature(const_cell_new)]
109-
#![feature(const_nonzero_new)]
11093
#![cfg_attr(not(stage0), feature(doc_spotlight))]
11194

112-
#![cfg_attr(not(stage0), feature(const_min_value))]
113-
#![cfg_attr(not(stage0), feature(const_max_value))]
114-
#![cfg_attr(not(stage0), feature(const_atomic_bool_new))]
115-
#![cfg_attr(not(stage0), feature(const_atomic_isize_new))]
116-
#![cfg_attr(not(stage0), feature(const_atomic_usize_new))]
117-
#![cfg_attr(not(stage0), feature(const_atomic_i8_new))]
118-
#![cfg_attr(not(stage0), feature(const_atomic_u8_new))]
119-
#![cfg_attr(not(stage0), feature(const_atomic_i16_new))]
120-
#![cfg_attr(not(stage0), feature(const_atomic_u16_new))]
121-
#![cfg_attr(not(stage0), feature(const_atomic_i32_new))]
122-
#![cfg_attr(not(stage0), feature(const_atomic_u32_new))]
123-
#![cfg_attr(not(stage0), feature(const_atomic_i64_new))]
124-
#![cfg_attr(not(stage0), feature(const_atomic_u64_new))]
125-
#![cfg_attr(not(stage0), feature(const_unsafe_cell_new))]
126-
#![cfg_attr(not(stage0), feature(const_cell_new))]
127-
#![cfg_attr(not(stage0), feature(const_nonzero_new))]
128-
12995
#[prelude_import]
13096
#[allow(unused)]
13197
use prelude::v1::*;

src/libcore/mem.rs

-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ pub fn forget<T>(t: T) {
311311
/// [alignment]: ./fn.align_of.html
312312
#[inline]
313313
#[stable(feature = "rust1", since = "1.0.0")]
314-
#[rustc_const_unstable(feature = "const_size_of")]
315314
pub const fn size_of<T>() -> usize {
316315
unsafe { intrinsics::size_of::<T>() }
317316
}
@@ -403,7 +402,6 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
403402
/// ```
404403
#[inline]
405404
#[stable(feature = "rust1", since = "1.0.0")]
406-
#[rustc_const_unstable(feature = "const_align_of")]
407405
pub const fn align_of<T>() -> usize {
408406
unsafe { intrinsics::min_align_of::<T>() }
409407
}

src/libcore/nonzero.rs

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ impl<T: Zeroable> NonZero<T> {
7171
#[unstable(feature = "nonzero",
7272
reason = "needs an RFC to flesh out the design",
7373
issue = "27730")]
74-
#[rustc_const_unstable(feature = "const_nonzero_new")]
7574
#[inline]
7675
pub const unsafe fn new_unchecked(inner: T) -> Self {
7776
NonZero(inner)

src/libcore/num/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ macro_rules! int_impl {
110110
/// assert_eq!(i8::min_value(), -128);
111111
/// ```
112112
#[stable(feature = "rust1", since = "1.0.0")]
113-
#[rustc_const_unstable(feature = "const_min_value")]
114113
#[inline]
115114
pub const fn min_value() -> Self {
116115
!0 ^ ((!0 as $UnsignedT) >> 1) as Self
@@ -124,7 +123,6 @@ macro_rules! int_impl {
124123
/// assert_eq!(i8::max_value(), 127);
125124
/// ```
126125
#[stable(feature = "rust1", since = "1.0.0")]
127-
#[rustc_const_unstable(feature = "const_max_value")]
128126
#[inline]
129127
pub const fn max_value() -> Self {
130128
!Self::min_value()
@@ -1283,7 +1281,6 @@ macro_rules! uint_impl {
12831281
/// assert_eq!(u8::min_value(), 0);
12841282
/// ```
12851283
#[stable(feature = "rust1", since = "1.0.0")]
1286-
#[rustc_const_unstable(feature = "const_min_value")]
12871284
#[inline]
12881285
pub const fn min_value() -> Self { 0 }
12891286

@@ -1295,7 +1292,6 @@ macro_rules! uint_impl {
12951292
/// assert_eq!(u8::max_value(), 255);
12961293
/// ```
12971294
#[stable(feature = "rust1", since = "1.0.0")]
1298-
#[rustc_const_unstable(feature = "const_max_value")]
12991295
#[inline]
13001296
pub const fn max_value() -> Self { !0 }
13011297

src/libcore/ptr.rs

-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
7474
/// ```
7575
#[inline]
7676
#[stable(feature = "rust1", since = "1.0.0")]
77-
#[rustc_const_unstable(feature = "const_ptr_null")]
7877
pub const fn null<T>() -> *const T { 0 as *const T }
7978

8079
/// Creates a null mutable raw pointer.
@@ -89,7 +88,6 @@ pub const fn null<T>() -> *const T { 0 as *const T }
8988
/// ```
9089
#[inline]
9190
#[stable(feature = "rust1", since = "1.0.0")]
92-
#[rustc_const_unstable(feature = "const_ptr_null_mut")]
9391
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
9492

9593
/// Swaps the values at two mutable locations of the same type, without
@@ -2339,7 +2337,6 @@ impl<T: ?Sized> Unique<T> {
23392337
///
23402338
/// `ptr` must be non-null.
23412339
#[unstable(feature = "unique", issue = "27730")]
2342-
#[rustc_const_unstable(feature = "const_unique_new")]
23432340
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
23442341
Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData }
23452342
}
@@ -2474,7 +2471,6 @@ impl<T: ?Sized> Shared<T> {
24742471
///
24752472
/// `ptr` must be non-null.
24762473
#[unstable(feature = "shared", issue = "27730")]
2477-
#[rustc_const_unstable(feature = "const_shared_new")]
24782474
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
24792475
Shared { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData }
24802476
}

src/libcore/sync/atomic.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ impl AtomicBool {
243243
/// ```
244244
#[inline]
245245
#[stable(feature = "rust1", since = "1.0.0")]
246-
#[rustc_const_unstable(feature = "const_atomic_bool_new")]
247246
pub const fn new(v: bool) -> AtomicBool {
248247
AtomicBool { v: UnsafeCell::new(v as u8) }
249248
}
@@ -657,7 +656,6 @@ impl<T> AtomicPtr<T> {
657656
/// ```
658657
#[inline]
659658
#[stable(feature = "rust1", since = "1.0.0")]
660-
#[rustc_const_unstable(feature = "const_atomic_ptr_new")]
661659
pub const fn new(p: *mut T) -> AtomicPtr<T> {
662660
AtomicPtr { p: UnsafeCell::new(p) }
663661
}
@@ -936,7 +934,7 @@ impl<T> From<*mut T> for AtomicPtr<T> {
936934

937935
#[cfg(target_has_atomic = "ptr")]
938936
macro_rules! atomic_int {
939-
($stable:meta, $const_unstable:meta,
937+
($stable:meta,
940938
$stable_cxchg:meta,
941939
$stable_debug:meta,
942940
$stable_access:meta,
@@ -1005,7 +1003,6 @@ macro_rules! atomic_int {
10051003
/// ```
10061004
#[inline]
10071005
#[$stable]
1008-
#[$const_unstable]
10091006
pub const fn new(v: $int_type) -> Self {
10101007
$atomic_type {v: UnsafeCell::new(v)}
10111008
}
@@ -1369,7 +1366,6 @@ macro_rules! atomic_int {
13691366
#[cfg(target_has_atomic = "8")]
13701367
atomic_int! {
13711368
unstable(feature = "integer_atomics", issue = "32976"),
1372-
rustc_const_unstable(feature = "const_atomic_i8_new"),
13731369
unstable(feature = "integer_atomics", issue = "32976"),
13741370
unstable(feature = "integer_atomics", issue = "32976"),
13751371
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1379,7 +1375,6 @@ atomic_int! {
13791375
#[cfg(target_has_atomic = "8")]
13801376
atomic_int! {
13811377
unstable(feature = "integer_atomics", issue = "32976"),
1382-
rustc_const_unstable(feature = "const_atomic_u8_new"),
13831378
unstable(feature = "integer_atomics", issue = "32976"),
13841379
unstable(feature = "integer_atomics", issue = "32976"),
13851380
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1389,7 +1384,6 @@ atomic_int! {
13891384
#[cfg(target_has_atomic = "16")]
13901385
atomic_int! {
13911386
unstable(feature = "integer_atomics", issue = "32976"),
1392-
rustc_const_unstable(feature = "const_atomic_i16_new"),
13931387
unstable(feature = "integer_atomics", issue = "32976"),
13941388
unstable(feature = "integer_atomics", issue = "32976"),
13951389
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1399,7 +1393,6 @@ atomic_int! {
13991393
#[cfg(target_has_atomic = "16")]
14001394
atomic_int! {
14011395
unstable(feature = "integer_atomics", issue = "32976"),
1402-
rustc_const_unstable(feature = "const_atomic_u16_new"),
14031396
unstable(feature = "integer_atomics", issue = "32976"),
14041397
unstable(feature = "integer_atomics", issue = "32976"),
14051398
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1409,7 +1402,6 @@ atomic_int! {
14091402
#[cfg(target_has_atomic = "32")]
14101403
atomic_int! {
14111404
unstable(feature = "integer_atomics", issue = "32976"),
1412-
rustc_const_unstable(feature = "const_atomic_i32_new"),
14131405
unstable(feature = "integer_atomics", issue = "32976"),
14141406
unstable(feature = "integer_atomics", issue = "32976"),
14151407
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1419,7 +1411,6 @@ atomic_int! {
14191411
#[cfg(target_has_atomic = "32")]
14201412
atomic_int! {
14211413
unstable(feature = "integer_atomics", issue = "32976"),
1422-
rustc_const_unstable(feature = "const_atomic_u32_new"),
14231414
unstable(feature = "integer_atomics", issue = "32976"),
14241415
unstable(feature = "integer_atomics", issue = "32976"),
14251416
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1429,7 +1420,6 @@ atomic_int! {
14291420
#[cfg(target_has_atomic = "64")]
14301421
atomic_int! {
14311422
unstable(feature = "integer_atomics", issue = "32976"),
1432-
rustc_const_unstable(feature = "const_atomic_i64_new"),
14331423
unstable(feature = "integer_atomics", issue = "32976"),
14341424
unstable(feature = "integer_atomics", issue = "32976"),
14351425
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1439,7 +1429,6 @@ atomic_int! {
14391429
#[cfg(target_has_atomic = "64")]
14401430
atomic_int! {
14411431
unstable(feature = "integer_atomics", issue = "32976"),
1442-
rustc_const_unstable(feature = "const_atomic_u64_new"),
14431432
unstable(feature = "integer_atomics", issue = "32976"),
14441433
unstable(feature = "integer_atomics", issue = "32976"),
14451434
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1449,7 +1438,6 @@ atomic_int! {
14491438
#[cfg(target_has_atomic = "ptr")]
14501439
atomic_int!{
14511440
stable(feature = "rust1", since = "1.0.0"),
1452-
rustc_const_unstable(feature = "const_atomic_isize_new"),
14531441
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
14541442
stable(feature = "atomic_debug", since = "1.3.0"),
14551443
stable(feature = "atomic_access", since = "1.15.0"),
@@ -1459,7 +1447,6 @@ atomic_int!{
14591447
#[cfg(target_has_atomic = "ptr")]
14601448
atomic_int!{
14611449
stable(feature = "rust1", since = "1.0.0"),
1462-
rustc_const_unstable(feature = "const_atomic_usize_new"),
14631450
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
14641451
stable(feature = "atomic_debug", since = "1.3.0"),
14651452
stable(feature = "atomic_access", since = "1.15.0"),

src/libcore/tests/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@
4242
#![feature(try_trait)]
4343
#![feature(unique)]
4444

45-
#![feature(const_atomic_bool_new)]
46-
#![feature(const_atomic_usize_new)]
47-
#![feature(const_atomic_isize_new)]
48-
4945
extern crate core;
5046
extern crate test;
5147

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#![feature(underscore_lifetimes)]
6565
#![feature(trace_macros)]
6666
#![feature(test)]
67-
#![feature(const_atomic_bool_new)]
6867

6968
#![recursion_limit="512"]
7069

src/librustc_apfloat/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
#![deny(warnings)]
4646
#![forbid(unsafe_code)]
4747

48-
#![feature(const_max_value)]
49-
#![feature(const_min_value)]
5048
#![feature(i128_type)]
5149
#![feature(slice_patterns)]
5250
#![feature(try_from)]

src/librustc_const_eval/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#![feature(box_syntax)]
2626
#![feature(i128_type)]
2727

28-
#![feature(const_min_value)]
29-
3028
extern crate arena;
3129
#[macro_use] extern crate syntax;
3230
#[macro_use] extern crate log;

src/librustc_const_math/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#![feature(i128)]
2323
#![feature(i128_type)]
2424

25-
#![feature(const_min_value)]
26-
#![feature(const_max_value)]
27-
2825
extern crate rustc_apfloat;
2926

3027
extern crate syntax;

src/librustc_mir/diagnostics.rs

-4
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,6 @@ static B: &'static AtomicUsize = &A; // ok!
770770
You can also have this error while using a cell type:
771771
772772
```compile_fail,E0492
773-
#![feature(const_cell_new)]
774-
775773
use std::cell::Cell;
776774
777775
const A: Cell<usize> = Cell::new(1);
@@ -798,8 +796,6 @@ However, if you still wish to use these types, you can achieve this by an unsafe
798796
wrapper:
799797
800798
```
801-
#![feature(const_cell_new)]
802-
803799
use std::cell::Cell;
804800
use std::marker::Sync;
805801

src/librustc_trans/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#![feature(slice_patterns)]
3434
#![feature(conservative_impl_trait)]
3535

36-
#![feature(const_atomic_bool_new)]
37-
#![feature(const_once_new)]
38-
3936
use rustc::dep_graph::WorkProduct;
4037
use syntax_pos::symbol::Symbol;
4138

src/libstd/lib.rs

-11
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,6 @@
256256
#![feature(collections_range)]
257257
#![feature(compiler_builtins_lib)]
258258
#![feature(const_fn)]
259-
#![feature(const_max_value)]
260-
#![feature(const_atomic_bool_new)]
261-
#![feature(const_atomic_isize_new)]
262-
#![feature(const_atomic_usize_new)]
263-
#![feature(const_unsafe_cell_new)]
264-
#![feature(const_cell_new)]
265-
#![feature(const_once_new)]
266-
#![feature(const_ptr_null)]
267-
#![feature(const_ptr_null_mut)]
268259
#![feature(core_float)]
269260
#![feature(core_intrinsics)]
270261
#![feature(dropck_eyepatch)]
@@ -306,7 +297,6 @@
306297
#![feature(repr_align)]
307298
#![feature(repr_simd)]
308299
#![feature(rustc_attrs)]
309-
#![feature(rustc_const_unstable)]
310300
#![feature(shared)]
311301
#![feature(sip_hash_13)]
312302
#![feature(slice_bytes)]
@@ -331,7 +321,6 @@
331321
#![feature(doc_masked)]
332322
#![feature(doc_spotlight)]
333323
#![cfg_attr(test, feature(update_panic_count))]
334-
#![cfg_attr(windows, feature(const_atomic_ptr_new))]
335324
#![cfg_attr(windows, feature(used))]
336325

337326
#![default_lib_allocator]

src/libstd/sync/once.rs

-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ struct Finish {
156156
impl Once {
157157
/// Creates a new `Once` value.
158158
#[stable(feature = "once_new", since = "1.2.0")]
159-
#[rustc_const_unstable(feature = "const_once_new")]
160159
pub const fn new() -> Once {
161160
Once {
162161
state: AtomicUsize::new(INCOMPLETE),

src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// for the error message we see here.)
1818

1919
#![feature(rustc_private)]
20-
#![feature(const_atomic_usize_new)]
2120

2221
extern crate arena;
2322

0 commit comments

Comments
 (0)