Skip to content

Commit 0ee045e

Browse files
committed
Auto merge of #54835 - oli-obk:mögen_konstante_funktionen_doch_bitte_endlich_stabil_sein, r=Centril
Stabilize `min_const_fn` tracking issue: #53555 r? @Centril
2 parents 5a6f122 + fb04e26 commit 0ee045e

File tree

69 files changed

+145
-254
lines changed

Some content is hidden

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

69 files changed

+145
-254
lines changed

Diff for: src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#![feature(box_syntax)]
8787
#![feature(cfg_target_has_atomic)]
8888
#![feature(coerce_unsized)]
89-
#![feature(min_const_fn)]
89+
#![cfg_attr(stage0, feature(min_const_fn))]
9090
#![feature(core_intrinsics)]
9191
#![feature(custom_attribute)]
9292
#![feature(dropck_eyepatch)]

Diff for: src/liballoc/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![feature(allocator_api)]
1212
#![feature(alloc_system)]
1313
#![feature(box_syntax)]
14-
#![feature(min_const_fn)]
14+
#![cfg_attr(stage0, feature(min_const_fn))]
1515
#![feature(drain_filter)]
1616
#![feature(exact_size_is_empty)]
1717
#![feature(pattern)]

Diff for: src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#![feature(box_patterns)]
4444
#![feature(box_syntax)]
45-
#![feature(min_const_fn)]
45+
#![cfg_attr(stage0, feature(min_const_fn))]
4646
#![feature(core_intrinsics)]
4747
#![feature(drain_filter)]
4848
#![cfg_attr(windows, feature(libc))]

Diff for: src/librustc/ty/constness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
6565
_ => true,
6666
}
6767
} else {
68-
// users enabling the `const_fn` can do what they want
68+
// users enabling the `const_fn` feature gate can do what they want
6969
!self.sess.features_untracked().const_fn
7070
}
7171
}

Diff for: src/librustc_mir/diagnostics.rs

-18
Original file line numberDiff line numberDiff line change
@@ -665,24 +665,6 @@ fn main() {
665665
```
666666
"##,
667667

668-
E0022: r##"
669-
Constant functions are not allowed to mutate anything. Thus, binding to an
670-
argument with a mutable pattern is not allowed. For example,
671-
672-
```compile_fail
673-
const fn foo(mut x: u8) {
674-
// do stuff
675-
}
676-
```
677-
678-
Is incorrect because the function body may not mutate `x`.
679-
680-
Remove any mutable bindings from the argument list to fix this error. In case
681-
you need to mutate the argument, try lazily initializing a global variable
682-
instead of using a `const fn`, or refactoring the code to a functional style to
683-
avoid mutation if possible.
684-
"##,
685-
686668
E0133: r##"
687669
Unsafe code was used outside of an unsafe function or block.
688670

Diff for: src/librustc_target/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
html_root_url = "https://doc.rust-lang.org/nightly/")]
2323

2424
#![feature(box_syntax)]
25-
#![feature(min_const_fn)]
25+
#![cfg_attr(stage0, feature(min_const_fn))]
2626
#![feature(nll)]
2727
#![feature(slice_patterns)]
2828

Diff for: src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
#![feature(cfg_target_vendor)]
251251
#![feature(char_error_internals)]
252252
#![feature(compiler_builtins_lib)]
253-
#![feature(min_const_fn)]
253+
#![cfg_attr(stage0, feature(min_const_fn))]
254254
#![feature(const_int_ops)]
255255
#![feature(const_ip)]
256256
#![feature(const_raw_ptr_deref)]

Diff for: src/libsyntax/attr/builtin.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ pub struct Stability {
107107
pub level: StabilityLevel,
108108
pub feature: Symbol,
109109
pub rustc_depr: Option<RustcDeprecation>,
110-
/// `None` means the function is stable but needs to be allowed by the
111-
/// `min_const_fn` feature
110+
/// `None` means the function is stable but needs to be a stable const fn, too
112111
/// `Some` contains the feature gate required to be able to use the function
113112
/// as const fn
114113
pub const_stability: Option<Symbol>,

Diff for: src/libsyntax/feature_gate.rs

+3-21
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ use symbol::{keywords, Symbol};
4040
use std::{env};
4141

4242
macro_rules! set {
43-
// The const_fn feature also enables the min_const_fn feature, because `min_const_fn` allows
44-
// the declaration `const fn`, but the `const_fn` feature gate enables things inside those
45-
// functions that we do not want to expose to the user for now.
46-
(const_fn) => {{
47-
fn f(features: &mut Features, _: Span) {
48-
features.const_fn = true;
49-
features.min_const_fn = true;
50-
}
51-
f as fn(&mut Features, Span)
52-
}};
5343
($field: ident) => {{
5444
fn f(features: &mut Features, _: Span) {
5545
features.$field = true;
@@ -219,9 +209,6 @@ declare_features! (
219209
// Allows the definition of `const fn` functions with some advanced features.
220210
(active, const_fn, "1.2.0", Some(24111), None),
221211

222-
// Allows the definition of `const fn` functions.
223-
(active, min_const_fn, "1.30.0", Some(53555), None),
224-
225212
// Allows let bindings and destructuring in `const fn` functions and constants.
226213
(active, const_let, "1.22.1", Some(48821), None),
227214

@@ -690,6 +677,8 @@ declare_features! (
690677
(accepted, extern_prelude, "1.30.0", Some(44660), None),
691678
// Parentheses in patterns
692679
(accepted, pattern_parentheses, "1.31.0", Some(51087), None),
680+
// Allows the definition of `const fn` functions.
681+
(accepted, min_const_fn, "1.31.0", Some(53555), None),
693682
);
694683

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

18661852
match ii.node {
1867-
ast::ImplItemKind::Method(ref sig, _) => {
1868-
if sig.header.constness.node == ast::Constness::Const {
1869-
gate_feature_post!(&self, min_const_fn, ii.span, "const fn is unstable");
1870-
}
1871-
}
1853+
ast::ImplItemKind::Method(..) => {}
18721854
ast::ImplItemKind::Existential(..) => {
18731855
gate_feature_post!(
18741856
&self,

Diff for: src/test/codegen-units/item-collection/unreferenced-const-fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

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

16-
#![feature(min_const_fn)]
1716
#![deny(dead_code)]
1817
#![crate_type = "rlib"]
1918

Diff for: src/test/codegen/link-dead-code.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

13-
#![feature(min_const_fn)]
1413
#![crate_type = "rlib"]
1514

1615
// This test makes sure that, when -Clink-dead-code is specified, we generate

Diff for: src/test/compile-fail/issue-43733-2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(min_const_fn)]
1211
#![feature(cfg_target_thread_local, thread_local_internals)]
1312

1413
// On platforms *without* `#[thread_local]`, use

Diff for: src/test/mir-opt/lower_128bit_debug_test.rs

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

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

18-
#![feature(min_const_fn)]
19-
2018
static TEST_SIGNED: i128 = const_signed(-222);
2119
static TEST_UNSIGNED: u128 = const_unsigned(200);
2220

Diff for: src/test/mir-opt/lower_128bit_test.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

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

15-
#![feature(min_const_fn)]
16-
1715
static TEST_SIGNED: i128 = const_signed(-222);
1816
static TEST_UNSIGNED: u128 = const_unsigned(200);
1917

Diff for: src/test/run-fail/issue-29798.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

13-
#![feature(min_const_fn)]
1413
const fn test(x: usize) -> i32 {
1514
[42;5][x]
1615
}

Diff for: src/test/run-pass-fulldeps/newtype_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(min_const_fn, rustc_attrs, rustc_private, step_trait)]
1+
#![feature(rustc_attrs, rustc_private, step_trait)]
22

33
#[macro_use] extern crate rustc_data_structures;
44
extern crate rustc_serialize;

Diff for: src/test/run-pass/consts/auxiliary/const_fn_lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
// Crate that exports a const fn. Used for testing cross-crate.
1212

1313
#![crate_type="rlib"]
14-
#![feature(min_const_fn)]
1514

1615
pub const fn foo() -> usize { 22 }

Diff for: src/test/run-pass/consts/const-fn-const-eval.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// run-pass
1212
#![allow(dead_code)]
13-
#![feature(min_const_fn)]
1413

1514
const fn add(x: usize, y: usize) -> usize {
1615
x + y

Diff for: src/test/run-pass/consts/const-fn-method.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

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

1413
struct Foo { value: u32 }
1514

Diff for: src/test/run-pass/consts/const-fn-nested.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// run-pass
1212
// Test a call whose argument is the result of another call.
1313

14-
#![feature(min_const_fn)]
15-
1614
const fn sub(x: u32, y: u32) -> u32 {
1715
x - y
1816
}

Diff for: src/test/run-pass/consts/const-meth-pattern.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// run-pass
1212

13-
#![feature(min_const_fn)]
14-
1513
struct A;
1614

1715
impl A {

Diff for: src/test/run-pass/consts/const-pattern-variant.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// run-pass
1212
#![allow(unreachable_patterns)]
13-
#![feature(min_const_fn)]
1413

1514
#[derive(PartialEq, Eq)]
1615
enum Cake {

Diff for: src/test/run-pass/consts/const-size_of-align_of.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// run-pass
1212
#![allow(dead_code)]
13-
#![feature(min_const_fn)]
1413

1514
use std::mem;
1615

Diff for: src/test/run-pass/consts/const-unsafe-fn.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#![allow(dead_code)]
1313
// A quick test of 'unsafe const fn' functionality
1414

15-
#![feature(min_const_fn)]
16-
1715
const unsafe fn dummy(v: u32) -> u32 {
1816
!v
1917
}

Diff for: src/test/run-pass/consts/consts-in-patterns.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

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

1413
const FOO: isize = 10;
1514
const BAR: isize = 3;

Diff for: src/test/run-pass/ctfe/ice-48279.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

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

17-
#![feature(min_const_fn)]
18-
1917
#[derive(PartialEq, Eq)]
2018
pub struct NonZeroU32 {
2119
value: u32

Diff for: src/test/run-pass/ctfe/match-const-fn-structs.rs

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

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

16-
#![feature(min_const_fn)]
17-
1816
#[derive(Eq, PartialEq)]
1917
struct A { value: u32 }
2018

Diff for: src/test/run-pass/ctfe/return-in-const-fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

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

15-
#![feature(min_const_fn)]
1615
const fn foo(x: usize) -> usize {
1716
return x;
1817
}

Diff for: src/test/run-pass/issues/auxiliary/issue-36954.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(min_const_fn)]
1211
#![crate_type = "lib"]
1312

1413
const fn foo(i: i32) -> i32 {

Diff for: src/test/run-pass/issues/issue-29927.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// run-pass
1212
#![allow(dead_code)]
13-
#![feature(min_const_fn)]
1413
struct A {
1514
field: usize,
1615
}

Diff for: src/test/run-pass/issues/issue-33537.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

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

1413
const fn foo() -> *const i8 {
1514
b"foo" as *const _ as *const i8

Diff for: src/test/run-pass/issues/issue-37991.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

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

1413
const fn foo() -> i64 {
1514
3

Diff for: src/test/run-pass/issues/issue29927-1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// run-pass
1212
#![allow(dead_code)]
13-
#![feature(min_const_fn)]
1413
const fn f() -> usize {
1514
5
1615
}

Diff for: src/test/rustdoc/auxiliary/issue-27362.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// compile-flags: -Cmetadata=aux
1212

13-
#![feature(min_const_fn)]
14-
1513
pub const fn foo() {}
1614
pub const unsafe fn bar() {}
1715

Diff for: src/test/rustdoc/const-fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(min_const_fn)]
1211
#![crate_name = "foo"]
1312

1413
// @has foo/fn.bar.html

Diff for: src/test/rustdoc/const.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#![crate_type="lib"]
1212

13-
#![feature(min_const_fn)]
14-
1513
pub struct Foo;
1614

1715
impl Foo {

Diff for: src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0507]: cannot move out of borrowed content
2-
--> $DIR/move-in-static-initializer-issue-38520.rs:27:23
2+
--> $DIR/move-in-static-initializer-issue-38520.rs:25:23
33
|
44
LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
55
| ^^^ cannot move out of borrowed content
66

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

Diff for: src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0507]: cannot move out of borrowed content
2-
--> $DIR/move-in-static-initializer-issue-38520.rs:27:23
2+
--> $DIR/move-in-static-initializer-issue-38520.rs:25:23
33
|
44
LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
55
| ^^^ cannot move out of borrowed content
66

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

0 commit comments

Comments
 (0)