Skip to content

Commit 681e5da

Browse files
committed
change #![feature(const_fn)] to specific gates
1 parent a12d0d4 commit 681e5da

Some content is hidden

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

49 files changed

+127
-75
lines changed

src/libcore/cell.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ impl<T> Cell<T> {
329329
/// let c = Cell::new(5);
330330
/// ```
331331
#[stable(feature = "rust1", since = "1.0.0")]
332+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_cell_new"))]
332333
#[inline]
333334
pub const fn new(value: T) -> Cell<T> {
334335
Cell {
@@ -543,6 +544,7 @@ impl<T> RefCell<T> {
543544
/// let c = RefCell::new(5);
544545
/// ```
545546
#[stable(feature = "rust1", since = "1.0.0")]
547+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_refcell_new"))]
546548
#[inline]
547549
pub const fn new(value: T) -> RefCell<T> {
548550
RefCell {
@@ -1188,6 +1190,7 @@ impl<T> UnsafeCell<T> {
11881190
/// let uc = UnsafeCell::new(5);
11891191
/// ```
11901192
#[stable(feature = "rust1", since = "1.0.0")]
1193+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_unsafe_cell_new"))]
11911194
#[inline]
11921195
pub const fn new(value: T) -> UnsafeCell<T> {
11931196
UnsafeCell { value: value }

src/libcore/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,30 @@
8585
#![feature(prelude_import)]
8686
#![feature(repr_simd, platform_intrinsics)]
8787
#![feature(rustc_attrs)]
88+
#![cfg_attr(not(stage0), feature(rustc_const_unstable))]
8889
#![feature(specialization)]
8990
#![feature(staged_api)]
9091
#![feature(unboxed_closures)]
9192
#![feature(untagged_unions)]
9293
#![feature(unwind_attributes)]
9394

95+
#![cfg_attr(not(stage0), feature(const_min_value))]
96+
#![cfg_attr(not(stage0), feature(const_max_value))]
97+
#![cfg_attr(not(stage0), feature(const_atomic_bool_new))]
98+
#![cfg_attr(not(stage0), feature(const_atomic_isize_new))]
99+
#![cfg_attr(not(stage0), feature(const_atomic_usize_new))]
100+
#![cfg_attr(not(stage0), feature(const_atomic_i8_new))]
101+
#![cfg_attr(not(stage0), feature(const_atomic_u8_new))]
102+
#![cfg_attr(not(stage0), feature(const_atomic_i16_new))]
103+
#![cfg_attr(not(stage0), feature(const_atomic_u16_new))]
104+
#![cfg_attr(not(stage0), feature(const_atomic_i32_new))]
105+
#![cfg_attr(not(stage0), feature(const_atomic_u32_new))]
106+
#![cfg_attr(not(stage0), feature(const_atomic_i64_new))]
107+
#![cfg_attr(not(stage0), feature(const_atomic_u64_new))]
108+
#![cfg_attr(not(stage0), feature(const_unsafe_cell_new))]
109+
#![cfg_attr(not(stage0), feature(const_cell_new))]
110+
#![cfg_attr(not(stage0), feature(const_nonzero_new))]
111+
94112
#[prelude_import]
95113
#[allow(unused)]
96114
use prelude::v1::*;

src/libcore/mem.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ pub fn forget<T>(t: T) {
189189
/// ```
190190
#[inline]
191191
#[stable(feature = "rust1", since = "1.0.0")]
192+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_size_of"))]
192193
pub const fn size_of<T>() -> usize {
193194
unsafe { intrinsics::size_of::<T>() }
194195
}
@@ -280,6 +281,7 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
280281
/// ```
281282
#[inline]
282283
#[stable(feature = "rust1", since = "1.0.0")]
284+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_align_of"))]
283285
pub const fn align_of<T>() -> usize {
284286
unsafe { intrinsics::min_align_of::<T>() }
285287
}

src/libcore/nonzero.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ pub struct NonZero<T: Zeroable>(T);
6868
impl<T: Zeroable> NonZero<T> {
6969
/// Creates an instance of NonZero with the provided value.
7070
/// You must indeed ensure that the value is actually "non-zero".
71+
#[unstable(feature = "nonzero",
72+
reason = "needs an RFC to flesh out the design",
73+
issue = "27730")]
74+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_nonzero_new"))]
7175
#[inline]
7276
pub const unsafe fn new_unchecked(inner: T) -> Self {
7377
NonZero(inner)

src/libcore/num/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ macro_rules! int_impl {
109109
/// assert_eq!(i8::min_value(), -128);
110110
/// ```
111111
#[stable(feature = "rust1", since = "1.0.0")]
112+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))]
112113
#[inline]
113114
pub const fn min_value() -> Self {
114115
!0 ^ ((!0 as $UnsignedT) >> 1) as Self
@@ -122,6 +123,7 @@ macro_rules! int_impl {
122123
/// assert_eq!(i8::max_value(), 127);
123124
/// ```
124125
#[stable(feature = "rust1", since = "1.0.0")]
126+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))]
125127
#[inline]
126128
pub const fn max_value() -> Self {
127129
!Self::min_value()
@@ -1280,6 +1282,7 @@ macro_rules! uint_impl {
12801282
/// assert_eq!(u8::min_value(), 0);
12811283
/// ```
12821284
#[stable(feature = "rust1", since = "1.0.0")]
1285+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))]
12831286
#[inline]
12841287
pub const fn min_value() -> Self { 0 }
12851288

@@ -1291,6 +1294,7 @@ macro_rules! uint_impl {
12911294
/// assert_eq!(u8::max_value(), 255);
12921295
/// ```
12931296
#[stable(feature = "rust1", since = "1.0.0")]
1297+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))]
12941298
#[inline]
12951299
pub const fn max_value() -> Self { !0 }
12961300

src/libcore/ptr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
7676
/// ```
7777
#[inline]
7878
#[stable(feature = "rust1", since = "1.0.0")]
79+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_ptr_null"))]
7980
pub const fn null<T>() -> *const T { 0 as *const T }
8081

8182
/// Creates a null mutable raw pointer.
@@ -90,6 +91,7 @@ pub const fn null<T>() -> *const T { 0 as *const T }
9091
/// ```
9192
#[inline]
9293
#[stable(feature = "rust1", since = "1.0.0")]
94+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_ptr_null_mut"))]
9395
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
9496

9597
/// Swaps the values at two mutable locations of the same type, without
@@ -1097,6 +1099,8 @@ impl<T: ?Sized> Unique<T> {
10971099
/// # Safety
10981100
///
10991101
/// `ptr` must be non-null.
1102+
#[unstable(feature = "unique", issue = "27730")]
1103+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_unique_new"))]
11001104
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
11011105
Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData }
11021106
}
@@ -1230,6 +1234,8 @@ impl<T: ?Sized> Shared<T> {
12301234
/// # Safety
12311235
///
12321236
/// `ptr` must be non-null.
1237+
#[unstable(feature = "shared", issue = "27730")]
1238+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_shared_new"))]
12331239
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
12341240
Shared { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData }
12351241
}

src/libcore/sync/atomic.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ impl AtomicBool {
241241
/// ```
242242
#[inline]
243243
#[stable(feature = "rust1", since = "1.0.0")]
244+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_atomic_bool_new"))]
244245
pub const fn new(v: bool) -> AtomicBool {
245246
AtomicBool { v: UnsafeCell::new(v as u8) }
246247
}
@@ -649,6 +650,7 @@ impl<T> AtomicPtr<T> {
649650
/// ```
650651
#[inline]
651652
#[stable(feature = "rust1", since = "1.0.0")]
653+
#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_atomic_ptr_new"))]
652654
pub const fn new(p: *mut T) -> AtomicPtr<T> {
653655
AtomicPtr { p: UnsafeCell::new(p) }
654656
}
@@ -920,7 +922,7 @@ impl<T> AtomicPtr<T> {
920922

921923
#[cfg(target_has_atomic = "ptr")]
922924
macro_rules! atomic_int {
923-
($stable:meta,
925+
($stable:meta, $const_unstable:meta,
924926
$stable_cxchg:meta,
925927
$stable_debug:meta,
926928
$stable_access:meta,
@@ -969,6 +971,7 @@ macro_rules! atomic_int {
969971
/// ```
970972
#[inline]
971973
#[$stable]
974+
#[cfg_attr(not(stage0), $const_unstable)]
972975
pub const fn new(v: $int_type) -> Self {
973976
$atomic_type {v: UnsafeCell::new(v)}
974977
}
@@ -1332,6 +1335,7 @@ macro_rules! atomic_int {
13321335
#[cfg(target_has_atomic = "8")]
13331336
atomic_int! {
13341337
unstable(feature = "integer_atomics", issue = "32976"),
1338+
rustc_const_unstable(feature = "const_atomic_i8_new"),
13351339
unstable(feature = "integer_atomics", issue = "32976"),
13361340
unstable(feature = "integer_atomics", issue = "32976"),
13371341
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1340,6 +1344,7 @@ atomic_int! {
13401344
#[cfg(target_has_atomic = "8")]
13411345
atomic_int! {
13421346
unstable(feature = "integer_atomics", issue = "32976"),
1347+
rustc_const_unstable(feature = "const_atomic_u8_new"),
13431348
unstable(feature = "integer_atomics", issue = "32976"),
13441349
unstable(feature = "integer_atomics", issue = "32976"),
13451350
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1348,6 +1353,7 @@ atomic_int! {
13481353
#[cfg(target_has_atomic = "16")]
13491354
atomic_int! {
13501355
unstable(feature = "integer_atomics", issue = "32976"),
1356+
rustc_const_unstable(feature = "const_atomic_i16_new"),
13511357
unstable(feature = "integer_atomics", issue = "32976"),
13521358
unstable(feature = "integer_atomics", issue = "32976"),
13531359
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1356,6 +1362,7 @@ atomic_int! {
13561362
#[cfg(target_has_atomic = "16")]
13571363
atomic_int! {
13581364
unstable(feature = "integer_atomics", issue = "32976"),
1365+
rustc_const_unstable(feature = "const_atomic_u16_new"),
13591366
unstable(feature = "integer_atomics", issue = "32976"),
13601367
unstable(feature = "integer_atomics", issue = "32976"),
13611368
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1364,6 +1371,7 @@ atomic_int! {
13641371
#[cfg(target_has_atomic = "32")]
13651372
atomic_int! {
13661373
unstable(feature = "integer_atomics", issue = "32976"),
1374+
rustc_const_unstable(feature = "const_atomic_i32_new"),
13671375
unstable(feature = "integer_atomics", issue = "32976"),
13681376
unstable(feature = "integer_atomics", issue = "32976"),
13691377
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1372,6 +1380,7 @@ atomic_int! {
13721380
#[cfg(target_has_atomic = "32")]
13731381
atomic_int! {
13741382
unstable(feature = "integer_atomics", issue = "32976"),
1383+
rustc_const_unstable(feature = "const_atomic_u32_new"),
13751384
unstable(feature = "integer_atomics", issue = "32976"),
13761385
unstable(feature = "integer_atomics", issue = "32976"),
13771386
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1380,6 +1389,7 @@ atomic_int! {
13801389
#[cfg(target_has_atomic = "64")]
13811390
atomic_int! {
13821391
unstable(feature = "integer_atomics", issue = "32976"),
1392+
rustc_const_unstable(feature = "const_atomic_i64_new"),
13831393
unstable(feature = "integer_atomics", issue = "32976"),
13841394
unstable(feature = "integer_atomics", issue = "32976"),
13851395
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1388,6 +1398,7 @@ atomic_int! {
13881398
#[cfg(target_has_atomic = "64")]
13891399
atomic_int! {
13901400
unstable(feature = "integer_atomics", issue = "32976"),
1401+
rustc_const_unstable(feature = "const_atomic_u64_new"),
13911402
unstable(feature = "integer_atomics", issue = "32976"),
13921403
unstable(feature = "integer_atomics", issue = "32976"),
13931404
unstable(feature = "integer_atomics", issue = "32976"),
@@ -1396,6 +1407,7 @@ atomic_int! {
13961407
#[cfg(target_has_atomic = "ptr")]
13971408
atomic_int!{
13981409
stable(feature = "rust1", since = "1.0.0"),
1410+
rustc_const_unstable(feature = "const_atomic_isize_new"),
13991411
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
14001412
stable(feature = "atomic_debug", since = "1.3.0"),
14011413
stable(feature = "atomic_access", since = "1.15.0"),
@@ -1404,6 +1416,7 @@ atomic_int!{
14041416
#[cfg(target_has_atomic = "ptr")]
14051417
atomic_int!{
14061418
stable(feature = "rust1", since = "1.0.0"),
1419+
rustc_const_unstable(feature = "const_atomic_usize_new"),
14071420
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
14081421
stable(feature = "atomic_debug", since = "1.3.0"),
14091422
stable(feature = "atomic_access", since = "1.15.0"),

src/libcore/tests/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![deny(warnings)]
1212

1313
#![feature(box_syntax)]
14-
#![feature(const_fn)]
1514
#![feature(core_float)]
1615
#![feature(core_private_bignum)]
1716
#![feature(core_private_diy_float)]
@@ -42,6 +41,10 @@
4241
#![feature(try_from)]
4342
#![feature(unique)]
4443

44+
#![feature(const_atomic_bool_new)]
45+
#![feature(const_atomic_usize_new)]
46+
#![feature(const_atomic_isize_new)]
47+
4548
extern crate core;
4649
extern crate test;
4750
extern crate rand;

src/librustc/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#![feature(box_patterns)]
2323
#![feature(box_syntax)]
2424
#![feature(conservative_impl_trait)]
25-
#![feature(const_fn)]
2625
#![feature(core_intrinsics)]
2726
#![feature(i128_type)]
2827
#![cfg_attr(windows, feature(libc))]
@@ -36,6 +35,9 @@
3635
#![feature(trace_macros)]
3736
#![feature(test)]
3837

38+
#![cfg_attr(stage0, feature(const_fn))]
39+
#![cfg_attr(not(stage0), feature(const_atomic_bool_new))]
40+
3941
#![recursion_limit="256"]
4042

4143
extern crate arena;

src/librustc_apfloat/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545
#![deny(warnings)]
4646
#![forbid(unsafe_code)]
4747

48-
#![feature(const_fn)]
4948
#![feature(i128_type)]
5049
#![feature(slice_patterns)]
5150
#![feature(try_from)]
5251

52+
#![cfg_attr(stage0, feature(const_fn))]
53+
#![cfg_attr(not(stage0), feature(const_min_value))]
54+
#![cfg_attr(not(stage0), feature(const_max_value))]
55+
5356
#[macro_use]
5457
extern crate rustc_bitflags;
5558

src/librustc_const_eval/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
#![feature(slice_patterns)]
2424
#![feature(box_patterns)]
2525
#![feature(box_syntax)]
26-
#![feature(const_fn)]
2726
#![feature(i128_type)]
2827

28+
#![cfg_attr(stage0, feature(const_fn))]
29+
#![cfg_attr(not(stage0), feature(const_min_value))]
30+
2931
extern crate arena;
3032
#[macro_use] extern crate syntax;
3133
#[macro_use] extern crate log;

src/librustc_const_math/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
html_root_url = "https://doc.rust-lang.org/nightly/")]
2020
#![deny(warnings)]
2121

22-
#![feature(const_fn)]
2322
#![feature(i128)]
2423
#![feature(i128_type)]
2524

25+
#![cfg_attr(stage0, feature(const_fn))]
26+
#![cfg_attr(not(stage0), feature(const_min_value))]
27+
#![cfg_attr(not(stage0), feature(const_max_value))]
28+
2629
extern crate rustc_apfloat;
2730

2831
extern crate syntax;

src/librustc_mir/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static B: &'static AtomicUsize = &A; // ok!
384384
You can also have this error while using a cell type:
385385
386386
```compile_fail,E0492
387-
#![feature(const_fn)]
387+
#![feature(const_cell_new)]
388388
389389
use std::cell::Cell;
390390
@@ -412,7 +412,7 @@ However, if you still wish to use these types, you can achieve this by an unsafe
412412
wrapper:
413413
414414
```
415-
#![feature(const_fn)]
415+
#![feature(const_cell_new)]
416416
417417
use std::cell::Cell;
418418
use std::marker::Sync;

src/librustc_trans/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#![feature(box_patterns)]
2323
#![feature(box_syntax)]
24-
#![feature(const_fn)]
2524
#![feature(custom_attribute)]
2625
#![allow(unused_attributes)]
2726
#![feature(i128_type)]
@@ -31,6 +30,10 @@
3130
#![feature(slice_patterns)]
3231
#![feature(conservative_impl_trait)]
3332

33+
#![cfg_attr(stage0, feature(const_fn))]
34+
#![cfg_attr(not(stage0), feature(const_atomic_bool_new))]
35+
#![cfg_attr(not(stage0), feature(const_once_new))]
36+
3437
use rustc::dep_graph::WorkProduct;
3538
use syntax_pos::symbol::Symbol;
3639

src/librustc_trans_utils/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#![feature(box_patterns)]
2121
#![feature(box_syntax)]
22-
#![feature(const_fn)]
2322
#![feature(custom_attribute)]
2423
#![allow(unused_attributes)]
2524
#![feature(i128_type)]
@@ -28,6 +27,8 @@
2827
#![feature(slice_patterns)]
2928
#![feature(conservative_impl_trait)]
3029

30+
#![cfg_attr(stage0, feature(const_fn))]
31+
3132
extern crate rustc;
3233
extern crate syntax;
3334
extern crate syntax_pos;

0 commit comments

Comments
 (0)