diff options
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 3 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 18 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 2 | ||||
| -rw-r--r-- | src/libcore/nonzero.rs | 4 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 6 | ||||
| -rw-r--r-- | src/libcore/sync/atomic.rs | 15 | ||||
| -rw-r--r-- | src/libcore/tests/lib.rs | 5 |
8 files changed, 55 insertions, 2 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index e0a3b8d52f4..b9c5ff10f87 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -329,6 +329,7 @@ impl<T> Cell<T> { /// let c = Cell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_cell_new"))] #[inline] pub const fn new(value: T) -> Cell<T> { Cell { @@ -543,6 +544,7 @@ impl<T> RefCell<T> { /// let c = RefCell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_refcell_new"))] #[inline] pub const fn new(value: T) -> RefCell<T> { RefCell { @@ -1188,6 +1190,7 @@ impl<T> UnsafeCell<T> { /// let uc = UnsafeCell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_unsafe_cell_new"))] #[inline] pub const fn new(value: T) -> UnsafeCell<T> { UnsafeCell { value: value } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index c270c6ae0db..69612bd2a32 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -85,12 +85,30 @@ #![feature(prelude_import)] #![feature(repr_simd, platform_intrinsics)] #![feature(rustc_attrs)] +#![cfg_attr(not(stage0), feature(rustc_const_unstable))] #![feature(specialization)] #![feature(staged_api)] #![feature(unboxed_closures)] #![feature(untagged_unions)] #![feature(unwind_attributes)] +#![cfg_attr(not(stage0), feature(const_min_value))] +#![cfg_attr(not(stage0), feature(const_max_value))] +#![cfg_attr(not(stage0), feature(const_atomic_bool_new))] +#![cfg_attr(not(stage0), feature(const_atomic_isize_new))] +#![cfg_attr(not(stage0), feature(const_atomic_usize_new))] +#![cfg_attr(not(stage0), feature(const_atomic_i8_new))] +#![cfg_attr(not(stage0), feature(const_atomic_u8_new))] +#![cfg_attr(not(stage0), feature(const_atomic_i16_new))] +#![cfg_attr(not(stage0), feature(const_atomic_u16_new))] +#![cfg_attr(not(stage0), feature(const_atomic_i32_new))] +#![cfg_attr(not(stage0), feature(const_atomic_u32_new))] +#![cfg_attr(not(stage0), feature(const_atomic_i64_new))] +#![cfg_attr(not(stage0), feature(const_atomic_u64_new))] +#![cfg_attr(not(stage0), feature(const_unsafe_cell_new))] +#![cfg_attr(not(stage0), feature(const_cell_new))] +#![cfg_attr(not(stage0), feature(const_nonzero_new))] + #[prelude_import] #[allow(unused)] use prelude::v1::*; diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index bae1f4dee14..3e24623dad8 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -189,6 +189,7 @@ pub fn forget<T>(t: T) { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_size_of"))] pub const fn size_of<T>() -> usize { unsafe { intrinsics::size_of::<T>() } } @@ -280,6 +281,7 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_align_of"))] pub const fn align_of<T>() -> usize { unsafe { intrinsics::min_align_of::<T>() } } diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index 3ff1068b937..f075d825f5d 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -68,6 +68,10 @@ pub struct NonZero<T: Zeroable>(T); impl<T: Zeroable> NonZero<T> { /// Creates an instance of NonZero with the provided value. /// You must indeed ensure that the value is actually "non-zero". + #[unstable(feature = "nonzero", + reason = "needs an RFC to flesh out the design", + issue = "27730")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_nonzero_new"))] #[inline] pub const unsafe fn new_unchecked(inner: T) -> Self { NonZero(inner) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index c5175287ccf..bf31deae7a6 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -109,6 +109,7 @@ macro_rules! int_impl { /// assert_eq!(i8::min_value(), -128); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))] #[inline] pub const fn min_value() -> Self { !0 ^ ((!0 as $UnsignedT) >> 1) as Self @@ -122,6 +123,7 @@ macro_rules! int_impl { /// assert_eq!(i8::max_value(), 127); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))] #[inline] pub const fn max_value() -> Self { !Self::min_value() @@ -1280,6 +1282,7 @@ macro_rules! uint_impl { /// assert_eq!(u8::min_value(), 0); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))] #[inline] pub const fn min_value() -> Self { 0 } @@ -1291,6 +1294,7 @@ macro_rules! uint_impl { /// assert_eq!(u8::max_value(), 255); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))] #[inline] pub const fn max_value() -> Self { !0 } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 2e42e0dfd55..20aa881f4bc 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -76,6 +76,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_ptr_null"))] pub const fn null<T>() -> *const T { 0 as *const T } /// Creates a null mutable raw pointer. @@ -90,6 +91,7 @@ pub const fn null<T>() -> *const T { 0 as *const T } /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_ptr_null_mut"))] pub const fn null_mut<T>() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without @@ -1097,6 +1099,8 @@ impl<T: ?Sized> Unique<T> { /// # Safety /// /// `ptr` must be non-null. + #[unstable(feature = "unique", issue = "27730")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_unique_new"))] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData } } @@ -1230,6 +1234,8 @@ impl<T: ?Sized> Shared<T> { /// # Safety /// /// `ptr` must be non-null. + #[unstable(feature = "shared", issue = "27730")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_shared_new"))] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { Shared { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData } } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 510e01db0e9..09f3586a8c9 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -241,6 +241,7 @@ impl AtomicBool { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_atomic_bool_new"))] pub const fn new(v: bool) -> AtomicBool { AtomicBool { v: UnsafeCell::new(v as u8) } } @@ -649,6 +650,7 @@ impl<T> AtomicPtr<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_atomic_ptr_new"))] pub const fn new(p: *mut T) -> AtomicPtr<T> { AtomicPtr { p: UnsafeCell::new(p) } } @@ -920,7 +922,7 @@ impl<T> AtomicPtr<T> { #[cfg(target_has_atomic = "ptr")] macro_rules! atomic_int { - ($stable:meta, + ($stable:meta, $const_unstable:meta, $stable_cxchg:meta, $stable_debug:meta, $stable_access:meta, @@ -969,6 +971,7 @@ macro_rules! atomic_int { /// ``` #[inline] #[$stable] + #[cfg_attr(not(stage0), $const_unstable)] pub const fn new(v: $int_type) -> Self { $atomic_type {v: UnsafeCell::new(v)} } @@ -1332,6 +1335,7 @@ macro_rules! atomic_int { #[cfg(target_has_atomic = "8")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_i8_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1340,6 +1344,7 @@ atomic_int! { #[cfg(target_has_atomic = "8")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_u8_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1348,6 +1353,7 @@ atomic_int! { #[cfg(target_has_atomic = "16")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_i16_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1356,6 +1362,7 @@ atomic_int! { #[cfg(target_has_atomic = "16")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_u16_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1364,6 +1371,7 @@ atomic_int! { #[cfg(target_has_atomic = "32")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_i32_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1372,6 +1380,7 @@ atomic_int! { #[cfg(target_has_atomic = "32")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_u32_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1380,6 +1389,7 @@ atomic_int! { #[cfg(target_has_atomic = "64")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_i64_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1388,6 +1398,7 @@ atomic_int! { #[cfg(target_has_atomic = "64")] atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), + rustc_const_unstable(feature = "const_atomic_u64_new"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), @@ -1396,6 +1407,7 @@ atomic_int! { #[cfg(target_has_atomic = "ptr")] atomic_int!{ stable(feature = "rust1", since = "1.0.0"), + rustc_const_unstable(feature = "const_atomic_isize_new"), stable(feature = "extended_compare_and_swap", since = "1.10.0"), stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), @@ -1404,6 +1416,7 @@ atomic_int!{ #[cfg(target_has_atomic = "ptr")] atomic_int!{ stable(feature = "rust1", since = "1.0.0"), + rustc_const_unstable(feature = "const_atomic_usize_new"), stable(feature = "extended_compare_and_swap", since = "1.10.0"), stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index ab2022b1824..ce4d14b222c 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -11,7 +11,6 @@ #![deny(warnings)] #![feature(box_syntax)] -#![feature(const_fn)] #![feature(core_float)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] @@ -42,6 +41,10 @@ #![feature(try_from)] #![feature(unique)] +#![feature(const_atomic_bool_new)] +#![feature(const_atomic_usize_new)] +#![feature(const_atomic_isize_new)] + extern crate core; extern crate test; extern crate rand; |
