Skip to content

Commit

Permalink
Auto merge of #54835 - oli-obk:mögen_konstante_funktionen_doch_bitte_…
Browse files Browse the repository at this point in the history
…endlich_stabil_sein, r=Centril

Stabilize `min_const_fn`

tracking issue: #53555

r? @Centril
  • Loading branch information
bors committed Oct 7, 2018
2 parents 5a6f122 + fb04e26 commit 0ee045e
Show file tree
Hide file tree
Showing 69 changed files with 145 additions and 254 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#![feature(box_syntax)]
#![feature(cfg_target_has_atomic)]
#![feature(coerce_unsized)]
#![feature(min_const_fn)]
#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(core_intrinsics)]
#![feature(custom_attribute)]
#![feature(dropck_eyepatch)]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![feature(allocator_api)]
#![feature(alloc_system)]
#![feature(box_syntax)]
#![feature(min_const_fn)]
#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(pattern)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(min_const_fn)]
#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![cfg_attr(windows, feature(libc))]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/constness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
_ => true,
}
} else {
// users enabling the `const_fn` can do what they want
// users enabling the `const_fn` feature gate can do what they want
!self.sess.features_untracked().const_fn
}
}
Expand Down
18 changes: 0 additions & 18 deletions src/librustc_mir/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,24 +665,6 @@ fn main() {
```
"##,

E0022: r##"
Constant functions are not allowed to mutate anything. Thus, binding to an
argument with a mutable pattern is not allowed. For example,
```compile_fail
const fn foo(mut x: u8) {
// do stuff
}
```
Is incorrect because the function body may not mutate `x`.
Remove any mutable bindings from the argument list to fix this error. In case
you need to mutate the argument, try lazily initializing a global variable
instead of using a `const fn`, or refactoring the code to a functional style to
avoid mutation if possible.
"##,

E0133: r##"
Unsafe code was used outside of an unsafe function or block.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]

#![feature(box_syntax)]
#![feature(min_const_fn)]
#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(nll)]
#![feature(slice_patterns)]

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
#![feature(cfg_target_vendor)]
#![feature(char_error_internals)]
#![feature(compiler_builtins_lib)]
#![feature(min_const_fn)]
#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(const_int_ops)]
#![feature(const_ip)]
#![feature(const_raw_ptr_deref)]
Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/attr/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ pub struct Stability {
pub level: StabilityLevel,
pub feature: Symbol,
pub rustc_depr: Option<RustcDeprecation>,
/// `None` means the function is stable but needs to be allowed by the
/// `min_const_fn` feature
/// `None` means the function is stable but needs to be a stable const fn, too
/// `Some` contains the feature gate required to be able to use the function
/// as const fn
pub const_stability: Option<Symbol>,
Expand Down
24 changes: 3 additions & 21 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ use symbol::{keywords, Symbol};
use std::{env};

macro_rules! set {
// The const_fn feature also enables the min_const_fn feature, because `min_const_fn` allows
// the declaration `const fn`, but the `const_fn` feature gate enables things inside those
// functions that we do not want to expose to the user for now.
(const_fn) => {{
fn f(features: &mut Features, _: Span) {
features.const_fn = true;
features.min_const_fn = true;
}
f as fn(&mut Features, Span)
}};
($field: ident) => {{
fn f(features: &mut Features, _: Span) {
features.$field = true;
Expand Down Expand Up @@ -219,9 +209,6 @@ declare_features! (
// Allows the definition of `const fn` functions with some advanced features.
(active, const_fn, "1.2.0", Some(24111), None),

// Allows the definition of `const fn` functions.
(active, min_const_fn, "1.30.0", Some(53555), None),

// Allows let bindings and destructuring in `const fn` functions and constants.
(active, const_let, "1.22.1", Some(48821), None),

Expand Down Expand Up @@ -690,6 +677,8 @@ declare_features! (
(accepted, extern_prelude, "1.30.0", Some(44660), None),
// Parentheses in patterns
(accepted, pattern_parentheses, "1.31.0", Some(51087), None),
// Allows the definition of `const fn` functions.
(accepted, min_const_fn, "1.31.0", Some(53555), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1807,9 +1796,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
if header.asyncness.is_async() {
gate_feature_post!(&self, async_await, span, "async fn is unstable");
}
if header.constness.node == ast::Constness::Const {
gate_feature_post!(&self, min_const_fn, span, "const fn is unstable");
}
// stability of const fn methods are covered in
// visit_trait_item and visit_impl_item below; this is
// because default methods don't pass through this
Expand Down Expand Up @@ -1864,11 +1850,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}

match ii.node {
ast::ImplItemKind::Method(ref sig, _) => {
if sig.header.constness.node == ast::Constness::Const {
gate_feature_post!(&self, min_const_fn, ii.span, "const fn is unstable");
}
}
ast::ImplItemKind::Method(..) => {}
ast::ImplItemKind::Existential(..) => {
gate_feature_post!(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

// NB: We do not expect *any* monomorphization to be generated here.

#![feature(min_const_fn)]
#![deny(dead_code)]
#![crate_type = "rlib"]

Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/link-dead-code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// compile-flags:-Clink-dead-code

#![feature(min_const_fn)]
#![crate_type = "rlib"]

// This test makes sure that, when -Clink-dead-code is specified, we generate
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/issue-43733-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(min_const_fn)]
#![feature(cfg_target_thread_local, thread_local_internals)]

// On platforms *without* `#[thread_local]`, use
Expand Down
2 changes: 0 additions & 2 deletions src/test/mir-opt/lower_128bit_debug_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

// compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=yes

#![feature(min_const_fn)]

static TEST_SIGNED: i128 = const_signed(-222);
static TEST_UNSIGNED: u128 = const_unsigned(200);

Expand Down
2 changes: 0 additions & 2 deletions src/test/mir-opt/lower_128bit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

// compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=no -O

#![feature(min_const_fn)]

static TEST_SIGNED: i128 = const_signed(-222);
static TEST_UNSIGNED: u128 = const_unsigned(200);

Expand Down
1 change: 0 additions & 1 deletion src/test/run-fail/issue-29798.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// error-pattern:index out of bounds: the len is 5 but the index is 5

#![feature(min_const_fn)]
const fn test(x: usize) -> i32 {
[42;5][x]
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/newtype_index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(min_const_fn, rustc_attrs, rustc_private, step_trait)]
#![feature(rustc_attrs, rustc_private, step_trait)]

#[macro_use] extern crate rustc_data_structures;
extern crate rustc_serialize;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/consts/auxiliary/const_fn_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
// Crate that exports a const fn. Used for testing cross-crate.

#![crate_type="rlib"]
#![feature(min_const_fn)]

pub const fn foo() -> usize { 22 }
1 change: 0 additions & 1 deletion src/test/run-pass/consts/const-fn-const-eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// run-pass
#![allow(dead_code)]
#![feature(min_const_fn)]

const fn add(x: usize, y: usize) -> usize {
x + y
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/consts/const-fn-method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// run-pass
#![feature(min_const_fn)]

struct Foo { value: u32 }

Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/consts/const-fn-nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// run-pass
// Test a call whose argument is the result of another call.

#![feature(min_const_fn)]

const fn sub(x: u32, y: u32) -> u32 {
x - y
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/consts/const-meth-pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// run-pass

#![feature(min_const_fn)]

struct A;

impl A {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/consts/const-pattern-variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// run-pass
#![allow(unreachable_patterns)]
#![feature(min_const_fn)]

#[derive(PartialEq, Eq)]
enum Cake {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/consts/const-size_of-align_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// run-pass
#![allow(dead_code)]
#![feature(min_const_fn)]

use std::mem;

Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/consts/const-unsafe-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#![allow(dead_code)]
// A quick test of 'unsafe const fn' functionality

#![feature(min_const_fn)]

const unsafe fn dummy(v: u32) -> u32 {
!v
}
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/consts/consts-in-patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// run-pass
#![feature(min_const_fn)]

const FOO: isize = 10;
const BAR: isize = 3;
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/ctfe/ice-48279.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

// https://github.com/rust-lang/rust/issues/48279

#![feature(min_const_fn)]

#[derive(PartialEq, Eq)]
pub struct NonZeroU32 {
value: u32
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/ctfe/match-const-fn-structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

// https://github.com/rust-lang/rust/issues/46114

#![feature(min_const_fn)]

#[derive(Eq, PartialEq)]
struct A { value: u32 }

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/ctfe/return-in-const-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

// https://github.com/rust-lang/rust/issues/43754

#![feature(min_const_fn)]
const fn foo(x: usize) -> usize {
return x;
}
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/auxiliary/issue-36954.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(min_const_fn)]
#![crate_type = "lib"]

const fn foo(i: i32) -> i32 {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-29927.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// run-pass
#![allow(dead_code)]
#![feature(min_const_fn)]
struct A {
field: usize,
}
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-33537.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// run-pass
#![feature(min_const_fn)]

const fn foo() -> *const i8 {
b"foo" as *const _ as *const i8
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-37991.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// run-pass
#![feature(min_const_fn)]

const fn foo() -> i64 {
3
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue29927-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// run-pass
#![allow(dead_code)]
#![feature(min_const_fn)]
const fn f() -> usize {
5
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/rustdoc/auxiliary/issue-27362.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// compile-flags: -Cmetadata=aux

#![feature(min_const_fn)]

pub const fn foo() {}
pub const unsafe fn bar() {}

Expand Down
1 change: 0 additions & 1 deletion src/test/rustdoc/const-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(min_const_fn)]
#![crate_name = "foo"]

// @has foo/fn.bar.html
Expand Down
2 changes: 0 additions & 2 deletions src/test/rustdoc/const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#![crate_type="lib"]

#![feature(min_const_fn)]

pub struct Foo;

impl Foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/move-in-static-initializer-issue-38520.rs:27:23
--> $DIR/move-in-static-initializer-issue-38520.rs:25:23
|
LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
| ^^^ cannot move out of borrowed content

error[E0507]: cannot move out of borrowed content
--> $DIR/move-in-static-initializer-issue-38520.rs:29:22
--> $DIR/move-in-static-initializer-issue-38520.rs:27:22
|
LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507
| ^^^ cannot move out of borrowed content
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/move-in-static-initializer-issue-38520.rs:27:23
--> $DIR/move-in-static-initializer-issue-38520.rs:25:23
|
LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
| ^^^ cannot move out of borrowed content

error[E0507]: cannot move out of borrowed content
--> $DIR/move-in-static-initializer-issue-38520.rs:29:22
--> $DIR/move-in-static-initializer-issue-38520.rs:27:22
|
LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507
| ^^^ cannot move out of borrowed content
Expand Down
Loading

0 comments on commit 0ee045e

Please sign in to comment.