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

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
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)]

src/liballoc/tests/lib.rs

Lines changed: 1 addition & 1 deletion
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)]

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
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))]

src/librustc/ty/constness.rs

Lines changed: 1 addition & 1 deletion
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
}

src/librustc_mir/diagnostics.rs

Lines changed: 0 additions & 18 deletions
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

src/librustc_target/lib.rs

Lines changed: 1 addition & 1 deletion
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

src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
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)]

src/libsyntax/attr/builtin.rs

Lines changed: 1 addition & 2 deletions
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>,

src/libsyntax/feature_gate.rs

Lines changed: 3 additions & 21 deletions
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,

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

Lines changed: 0 additions & 1 deletion
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

0 commit comments

Comments
 (0)