Stabilize const-calling existing const-fns in std

Fixes #46038
This commit is contained in:
Simon Sapin 2017-11-26 23:19:18 +01:00
parent 827cb0d61e
commit 6c5f53e65e
45 changed files with 8 additions and 164 deletions

View File

@ -329,7 +329,6 @@ impl<T> Cell<T> {
/// let c = Cell::new(5);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cell_new")]
#[inline]
pub const fn new(value: T) -> Cell<T> {
Cell {
@ -544,7 +543,6 @@ impl<T> RefCell<T> {
/// let c = RefCell::new(5);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_refcell_new")]
#[inline]
pub const fn new(value: T) -> RefCell<T> {
RefCell {
@ -1215,7 +1213,6 @@ impl<T> UnsafeCell<T> {
/// let uc = UnsafeCell::new(5);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_unsafe_cell_new")]
#[inline]
pub const fn new(value: T) -> UnsafeCell<T> {
UnsafeCell { value: value }

View File

@ -85,47 +85,13 @@
#![feature(prelude_import)]
#![feature(repr_simd, platform_intrinsics)]
#![feature(rustc_attrs)]
#![feature(rustc_const_unstable)]
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
#![feature(const_min_value)]
#![feature(const_max_value)]
#![feature(const_atomic_bool_new)]
#![feature(const_atomic_isize_new)]
#![feature(const_atomic_usize_new)]
#![feature(const_atomic_i8_new)]
#![feature(const_atomic_u8_new)]
#![feature(const_atomic_i16_new)]
#![feature(const_atomic_u16_new)]
#![feature(const_atomic_i32_new)]
#![feature(const_atomic_u32_new)]
#![feature(const_atomic_i64_new)]
#![feature(const_atomic_u64_new)]
#![feature(const_unsafe_cell_new)]
#![feature(const_cell_new)]
#![feature(const_nonzero_new)]
#![cfg_attr(not(stage0), feature(doc_spotlight))]
#![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::*;

View File

@ -311,7 +311,6 @@ pub fn forget<T>(t: T) {
/// [alignment]: ./fn.align_of.html
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_size_of")]
pub const fn size_of<T>() -> usize {
unsafe { intrinsics::size_of::<T>() }
}
@ -403,7 +402,6 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_align_of")]
pub const fn align_of<T>() -> usize {
unsafe { intrinsics::min_align_of::<T>() }
}

View File

@ -71,7 +71,6 @@ impl<T: Zeroable> NonZero<T> {
#[unstable(feature = "nonzero",
reason = "needs an RFC to flesh out the design",
issue = "27730")]
#[rustc_const_unstable(feature = "const_nonzero_new")]
#[inline]
pub const unsafe fn new_unchecked(inner: T) -> Self {
NonZero(inner)

View File

@ -110,7 +110,6 @@ macro_rules! int_impl {
/// assert_eq!(i8::min_value(), -128);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_min_value")]
#[inline]
pub const fn min_value() -> Self {
!0 ^ ((!0 as $UnsignedT) >> 1) as Self
@ -124,7 +123,6 @@ macro_rules! int_impl {
/// assert_eq!(i8::max_value(), 127);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_max_value")]
#[inline]
pub const fn max_value() -> Self {
!Self::min_value()
@ -1283,7 +1281,6 @@ macro_rules! uint_impl {
/// assert_eq!(u8::min_value(), 0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_min_value")]
#[inline]
pub const fn min_value() -> Self { 0 }
@ -1295,7 +1292,6 @@ macro_rules! uint_impl {
/// assert_eq!(u8::max_value(), 255);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_max_value")]
#[inline]
pub const fn max_value() -> Self { !0 }

View File

@ -74,7 +74,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ptr_null")]
pub const fn null<T>() -> *const T { 0 as *const T }
/// Creates a null mutable raw pointer.
@ -89,7 +88,6 @@ pub const fn null<T>() -> *const T { 0 as *const T }
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[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
@ -2339,7 +2337,6 @@ impl<T: ?Sized> Unique<T> {
///
/// `ptr` must be non-null.
#[unstable(feature = "unique", issue = "27730")]
#[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 }
}
@ -2474,7 +2471,6 @@ impl<T: ?Sized> Shared<T> {
///
/// `ptr` must be non-null.
#[unstable(feature = "shared", issue = "27730")]
#[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 }
}

View File

@ -243,7 +243,6 @@ impl AtomicBool {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_atomic_bool_new")]
pub const fn new(v: bool) -> AtomicBool {
AtomicBool { v: UnsafeCell::new(v as u8) }
}
@ -657,7 +656,6 @@ impl<T> AtomicPtr<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_atomic_ptr_new")]
pub const fn new(p: *mut T) -> AtomicPtr<T> {
AtomicPtr { p: UnsafeCell::new(p) }
}
@ -936,7 +934,7 @@ impl<T> From<*mut T> for AtomicPtr<T> {
#[cfg(target_has_atomic = "ptr")]
macro_rules! atomic_int {
($stable:meta, $const_unstable:meta,
($stable:meta,
$stable_cxchg:meta,
$stable_debug:meta,
$stable_access:meta,
@ -1005,7 +1003,6 @@ macro_rules! atomic_int {
/// ```
#[inline]
#[$stable]
#[$const_unstable]
pub const fn new(v: $int_type) -> Self {
$atomic_type {v: UnsafeCell::new(v)}
}
@ -1369,7 +1366,6 @@ 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"),
@ -1379,7 +1375,6 @@ 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"),
@ -1389,7 +1384,6 @@ 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"),
@ -1399,7 +1393,6 @@ 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"),
@ -1409,7 +1402,6 @@ 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"),
@ -1419,7 +1411,6 @@ 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"),
@ -1429,7 +1420,6 @@ 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"),
@ -1439,7 +1429,6 @@ 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"),
@ -1449,7 +1438,6 @@ 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"),
@ -1459,7 +1447,6 @@ 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"),

View File

@ -42,10 +42,6 @@
#![feature(try_trait)]
#![feature(unique)]
#![feature(const_atomic_bool_new)]
#![feature(const_atomic_usize_new)]
#![feature(const_atomic_isize_new)]
extern crate core;
extern crate test;

View File

@ -64,7 +64,6 @@
#![feature(underscore_lifetimes)]
#![feature(trace_macros)]
#![feature(test)]
#![feature(const_atomic_bool_new)]
#![recursion_limit="512"]

View File

@ -45,8 +45,6 @@
#![deny(warnings)]
#![forbid(unsafe_code)]
#![feature(const_max_value)]
#![feature(const_min_value)]
#![feature(i128_type)]
#![feature(slice_patterns)]
#![feature(try_from)]

View File

@ -25,8 +25,6 @@
#![feature(box_syntax)]
#![feature(i128_type)]
#![feature(const_min_value)]
extern crate arena;
#[macro_use] extern crate syntax;
#[macro_use] extern crate log;

View File

@ -22,9 +22,6 @@
#![feature(i128)]
#![feature(i128_type)]
#![feature(const_min_value)]
#![feature(const_max_value)]
extern crate rustc_apfloat;
extern crate syntax;

View File

@ -770,8 +770,6 @@ static B: &'static AtomicUsize = &A; // ok!
You can also have this error while using a cell type:
```compile_fail,E0492
#![feature(const_cell_new)]
use std::cell::Cell;
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
wrapper:
```
#![feature(const_cell_new)]
use std::cell::Cell;
use std::marker::Sync;

View File

@ -33,9 +33,6 @@
#![feature(slice_patterns)]
#![feature(conservative_impl_trait)]
#![feature(const_atomic_bool_new)]
#![feature(const_once_new)]
use rustc::dep_graph::WorkProduct;
use syntax_pos::symbol::Symbol;

View File

@ -256,15 +256,6 @@
#![feature(collections_range)]
#![feature(compiler_builtins_lib)]
#![feature(const_fn)]
#![feature(const_max_value)]
#![feature(const_atomic_bool_new)]
#![feature(const_atomic_isize_new)]
#![feature(const_atomic_usize_new)]
#![feature(const_unsafe_cell_new)]
#![feature(const_cell_new)]
#![feature(const_once_new)]
#![feature(const_ptr_null)]
#![feature(const_ptr_null_mut)]
#![feature(core_float)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
@ -306,7 +297,6 @@
#![feature(repr_align)]
#![feature(repr_simd)]
#![feature(rustc_attrs)]
#![feature(rustc_const_unstable)]
#![feature(shared)]
#![feature(sip_hash_13)]
#![feature(slice_bytes)]
@ -331,7 +321,6 @@
#![feature(doc_masked)]
#![feature(doc_spotlight)]
#![cfg_attr(test, feature(update_panic_count))]
#![cfg_attr(windows, feature(const_atomic_ptr_new))]
#![cfg_attr(windows, feature(used))]
#![default_lib_allocator]

View File

@ -156,7 +156,6 @@ struct Finish {
impl Once {
/// Creates a new `Once` value.
#[stable(feature = "once_new", since = "1.2.0")]
#[rustc_const_unstable(feature = "const_once_new")]
pub const fn new() -> Once {
Once {
state: AtomicUsize::new(INCOMPLETE),

View File

@ -17,7 +17,6 @@
// for the error message we see here.)
#![feature(rustc_private)]
#![feature(const_atomic_usize_new)]
extern crate arena;

View File

@ -1,24 +0,0 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test use of const fns in std using individual feature gates.
use std::cell::Cell;
const CELL: Cell<i32> = Cell::new(42); //~ERROR not yet stable as a const fn
//~^HELP #![feature(const_cell_new)]
fn main() {
let v = CELL.get();
CELL.set(v+1);
assert_eq!(CELL.get(), v);
}

View File

@ -13,8 +13,6 @@
//
// (Compare against compile-fail/dropck_vec_cycle_checked.rs)
#![feature(const_atomic_usize_new)]
use std::cell::Cell;
use id::Id;

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(const_unsafe_cell_new)]
use std::cell::UnsafeCell;
const A: UnsafeCell<usize> = UnsafeCell::new(1);

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(const_fn, const_cell_new, const_unsafe_cell_new)]
#![feature(const_fn)]
#![feature(cfg_target_thread_local, thread_local_internals)]
// On platforms *without* `#[thread_local]`, use

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax, const_refcell_new)]
#![feature(box_syntax)]
use std::cell::RefCell;

View File

@ -15,7 +15,6 @@
#![allow(dead_code, unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(const_unsafe_cell_new)]
#![feature(static_mutex)]
// This test makes sure that the compiler doesn't crash when trying to assign

View File

@ -12,7 +12,6 @@
#![feature(rustc_private)]
#![feature(sort_unstable)]
#![feature(const_atomic_usize_new)]
extern crate rand;

View File

@ -11,7 +11,6 @@
// no-prefer-dynamic
#![allow(dead_code)]
#![feature(const_atomic_usize_new)]
// check dtor calling order when casting enums.

View File

@ -12,8 +12,6 @@
// `Item` originates in a where-clause, not the declaration of
// `T`. Issue #20300.
#![feature(const_atomic_usize_new)]
use std::marker::{PhantomData};
use std::sync::atomic::{AtomicUsize};
use std::sync::atomic::Ordering::SeqCst;

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(const_atomic_usize_new)]
use std::sync::atomic;
pub const C1: usize = 1;

View File

@ -9,7 +9,6 @@
// except according to those terms.
#![feature(cfg_target_thread_local, const_fn, thread_local)]
#![feature(const_cell_new)]
#![crate_type = "lib"]
#[cfg(target_thread_local)]

View File

@ -13,8 +13,6 @@
// ignore-emscripten no threads support
#![feature(const_atomic_usize_new)]
use std::thread;
use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -13,8 +13,6 @@
// ignore-emscripten no threads support
#![feature(const_atomic_usize_new)]
use std::thread;
use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test use of const fns in std using individual feature gates.
#![feature(const_cell_new)]
// Test use of stabilized const fns in std formerly using individual feature gates.
use std::cell::Cell;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(const_fn, const_size_of, const_align_of)]
#![feature(const_fn)]
use std::mem;

View File

@ -10,9 +10,6 @@
// pretty-expanded FIXME #23616
#![feature(core)]
#![feature(const_unsafe_cell_new)]
use std::marker;
use std::cell::UnsafeCell;

View File

@ -10,10 +10,6 @@
// aux-build:issue-17718-aux.rs
#![feature(core)]
#![feature(const_atomic_usize_new)]
extern crate issue_17718_aux as other;
use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -12,8 +12,6 @@
// created via FRU and control-flow breaks in the middle of
// construction.
#![feature(const_atomic_usize_new)]
use std::sync::atomic::{Ordering, AtomicUsize};
#[derive(Debug)]

View File

@ -12,8 +12,6 @@
// Check that the destructors of simple enums are run on unwinding
#![feature(const_atomic_usize_new)]
use std::sync::atomic::{Ordering, AtomicUsize};
use std::thread;

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(const_atomic_usize_new)]
use std::sync::atomic::{Ordering, AtomicUsize};
use std::mem;

View File

@ -14,8 +14,6 @@
// the contents implement Drop and we hit a panic in the middle of
// construction.
#![feature(const_atomic_usize_new)]
use std::thread;
use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -11,7 +11,6 @@
// ignore-emscripten no threads support
#![feature(panic_handler, std_panic)]
#![feature(const_atomic_usize_new)]
use std::sync::atomic::{AtomicUsize, Ordering};
use std::panic;

View File

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(panic_handler, std_panic)]
#![feature(const_atomic_usize_new)]
// ignore-emscripten no threads support

View File

@ -11,8 +11,6 @@
// Checks that functional-record-update order-of-eval is as expected
// even when no Drop-implementations are involved.
#![feature(const_atomic_usize_new)]
use std::sync::atomic::{Ordering, AtomicUsize};
struct W { wrapped: u32 }

View File

@ -11,8 +11,6 @@
// Checks that struct-literal expression order-of-eval is as expected
// even when no Drop-implementations are involved.
#![feature(const_atomic_usize_new)]
use std::sync::atomic::{Ordering, AtomicUsize};
struct W { wrapped: u32 }

View File

@ -13,7 +13,7 @@
//
// (Compare against compile-fail/dropck_vec_cycle_checked.rs)
#![feature(const_atomic_usize_new)]
use std::cell::Cell;
use id::Id;

View File

@ -12,7 +12,7 @@
//
// (Compare against compile-fail/dropck_arr_cycle_checked.rs)
#![feature(const_atomic_usize_new)]
use std::cell::Cell;
use id::Id;

View File

@ -23,7 +23,7 @@
// conditions above to be satisfied, meaning that if the dropck is
// sound, it should reject this code.
#![feature(const_atomic_usize_new)]
use std::cell::Cell;
use id::Id;