Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk

remove const_fn feature gate

Fixes https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`
This commit is contained in:
bors 2021-05-11 10:25:14 +00:00
commit 506e75cbf8
31 changed files with 55 additions and 136 deletions

View File

@ -274,9 +274,6 @@ declare_features! (
/// Allows using non lexical lifetimes (RFC 2094).
(active, nll, "1.0.0", Some(43234), None),
/// Allows the definition of `const` functions with some advanced features.
(active, const_fn, "1.2.0", Some(57563), None),
/// Allows associated type defaults.
(active, associated_type_defaults, "1.2.0", Some(29661), None),

View File

@ -136,6 +136,9 @@ declare_features! (
(removed, main, "1.53.0", Some(29634), None, None),
(removed, pub_macro_rules, "1.53.0", Some(78855), None,
Some("removed due to being incomplete, in particular it does not work across crates")),
/// Allows the definition of `const` functions with some advanced features.
(removed, const_fn, "1.54.0", Some(57563), None,
Some("split into finer-grained feature gates")),
// -------------------------------------------------------------------------
// feature-group-end: removed features

View File

@ -246,7 +246,6 @@
#![feature(const_cstr_unchecked)]
#![feature(const_fn_floating_point_arithmetic)]
#![feature(const_fn_transmute)]
#![feature(const_fn)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_io_structs)]
#![feature(const_ip)]

View File

@ -12,7 +12,7 @@ RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST/stage2/bin/rustc --edition=2018 \
# Download and build a single-file stress test benchmark on perf.rust-lang.org.
function pgo_perf_benchmark {
local PERF=9442def56a39d742bf27ebcc3e0614cf117e1bc2
local PERF=1e19fc4c6168d2f7596e512f42f358f245d8f09d
local github_prefix=https://raw.githubusercontent.com/rust-lang/rustc-perf/$PERF
local name=$1
curl -o /tmp/$name.rs $github_prefix/collector/benchmarks/$name/src/lib.rs

View File

@ -1,10 +0,0 @@
# `const_fn`
The tracking issue for this feature is: [#57563]
[#57563]: https://github.com/rust-lang/rust/issues/57563
------------------------
The `const_fn` feature enables additional functionality not stabilized in the
[minimal subset of `const_fn`](https://github.com/rust-lang/rust/issues/53555)

View File

@ -1,35 +0,0 @@
// Test use of advanced const fn without the `const_fn` feature gate.
const fn foo() -> usize { 0 } // ok
trait Foo {
const fn foo() -> u32; //~ ERROR functions in traits cannot be declared const
const fn bar() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
}
impl Foo for u32 {
const fn foo() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
}
trait Bar {}
impl dyn Bar {
const fn baz() -> u32 { 0 } // ok
}
static FOO: usize = foo();
const BAR: usize = foo();
macro_rules! constant {
($n:ident: $t:ty = $v:expr) => {
const $n: $t = $v;
}
}
constant! {
BAZ: usize = foo()
}
fn main() {
let x: [usize; foo()] = [];
}

View File

@ -1,21 +0,0 @@
error[E0379]: functions in traits cannot be declared const
--> $DIR/feature-gate-const_fn.rs:6:5
|
LL | const fn foo() -> u32;
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
--> $DIR/feature-gate-const_fn.rs:7:5
|
LL | const fn bar() -> u32 { 0 }
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
--> $DIR/feature-gate-const_fn.rs:11:5
|
LL | const fn foo() -> u32 { 0 }
| ^^^^^ functions in traits cannot be const
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0379`.

View File

@ -1,7 +1,5 @@
// Test internal const fn feature gate.
#![feature(const_fn)]
#[rustc_const_unstable(feature="fzzzzzt")] //~ stability attributes may not be used outside
pub const fn bazinga() {}

View File

@ -1,5 +1,5 @@
error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/feature-gate-rustc_const_unstable.rs:5:1
--> $DIR/feature-gate-rustc_const_unstable.rs:3:1
|
LL | #[rustc_const_unstable(feature="fzzzzzt")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -3,7 +3,7 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![feature(staged_api)]
#![feature(const_transmute, const_fn)]
#![feature(const_transmute)]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]

View File

@ -1,5 +1,3 @@
#![feature(const_fn)]
const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
//~^ ERROR type annotations needed

View File

@ -1,11 +1,11 @@
error[E0379]: functions in traits cannot be declared const
--> $DIR/issue-54954.rs:7:5
--> $DIR/issue-54954.rs:5:5
|
LL | const fn const_val<T: Sized>() -> usize {
| ^^^^^ functions in traits cannot be const
error[E0283]: type annotations needed
--> $DIR/issue-54954.rs:3:24
--> $DIR/issue-54954.rs:1:24
|
LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type

View File

@ -1,5 +1,3 @@
#![feature(const_fn)]
trait Foo {
fn f() -> u32;
const fn g(); //~ ERROR cannot be declared const

View File

@ -1,11 +1,11 @@
error[E0379]: functions in traits cannot be declared const
--> $DIR/const-fn-in-trait.rs:5:5
--> $DIR/const-fn-in-trait.rs:3:5
|
LL | const fn g();
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
--> $DIR/const-fn-in-trait.rs:9:5
--> $DIR/const-fn-in-trait.rs:7:5
|
LL | const fn f() -> u32 { 22 }
| ^^^^^ functions in traits cannot be const

View File

@ -3,7 +3,6 @@
// edition:2018
#![feature(const_extern_fn)]
#![feature(const_fn)]
fn main() {
async fn ff1() {} // OK.

View File

@ -1,5 +1,5 @@
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:13:5
--> $DIR/fn-header-semantic-fail.rs:12:5
|
LL | const async unsafe extern "C" fn ff5() {} // OK.
| ^^^^^-^^^^^------------------------------
@ -8,7 +8,7 @@ LL | const async unsafe extern "C" fn ff5() {} // OK.
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:17:9
--> $DIR/fn-header-semantic-fail.rs:16:9
|
LL | async fn ft1();
| -----^^^^^^^^^^
@ -19,19 +19,19 @@ LL | async fn ft1();
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:19:9
--> $DIR/fn-header-semantic-fail.rs:18:9
|
LL | const fn ft3();
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:21:9
--> $DIR/fn-header-semantic-fail.rs:20:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^ functions in traits cannot be const
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:21:9
--> $DIR/fn-header-semantic-fail.rs:20:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -42,7 +42,7 @@ LL | const async unsafe extern "C" fn ft5();
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:21:9
--> $DIR/fn-header-semantic-fail.rs:20:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^-^^^^^----------------------------
@ -51,7 +51,7 @@ LL | const async unsafe extern "C" fn ft5();
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:29:9
--> $DIR/fn-header-semantic-fail.rs:28:9
|
LL | async fn ft1() {}
| -----^^^^^^^^^^^^
@ -62,19 +62,19 @@ LL | async fn ft1() {}
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:32:9
--> $DIR/fn-header-semantic-fail.rs:31:9
|
LL | const fn ft3() {}
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^ functions in traits cannot be const
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -85,7 +85,7 @@ LL | const async unsafe extern "C" fn ft5() {}
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^-^^^^^------------------------------
@ -94,7 +94,7 @@ LL | const async unsafe extern "C" fn ft5() {}
| `const` because of this
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:46:9
--> $DIR/fn-header-semantic-fail.rs:45:9
|
LL | const async unsafe extern "C" fn fi5() {}
| ^^^^^-^^^^^------------------------------
@ -103,7 +103,7 @@ LL | const async unsafe extern "C" fn fi5() {}
| `const` because of this
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:51:18
--> $DIR/fn-header-semantic-fail.rs:50:18
|
LL | extern "C" {
| ---------- in this `extern` block
@ -116,7 +116,7 @@ LL | fn fe1();
| ^^
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:52:19
--> $DIR/fn-header-semantic-fail.rs:51:19
|
LL | extern "C" {
| ---------- in this `extern` block
@ -130,7 +130,7 @@ LL | fn fe2();
| ^^
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:53:18
--> $DIR/fn-header-semantic-fail.rs:52:18
|
LL | extern "C" {
| ---------- in this `extern` block
@ -144,7 +144,7 @@ LL | fn fe3();
| ^^
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:54:23
--> $DIR/fn-header-semantic-fail.rs:53:23
|
LL | extern "C" {
| ---------- in this `extern` block
@ -158,7 +158,7 @@ LL | fn fe4();
| ^^
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:55:42
--> $DIR/fn-header-semantic-fail.rs:54:42
|
LL | extern "C" {
| ---------- in this `extern` block
@ -172,7 +172,7 @@ LL | fn fe5();
| ^^
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:55:9
--> $DIR/fn-header-semantic-fail.rs:54:9
|
LL | const async unsafe extern "C" fn fe5();
| ^^^^^-^^^^^----------------------------
@ -181,7 +181,7 @@ LL | const async unsafe extern "C" fn fe5();
| `const` because of this
error[E0053]: method `ft1` has an incompatible type for trait
--> $DIR/fn-header-semantic-fail.rs:29:24
--> $DIR/fn-header-semantic-fail.rs:28:24
|
LL | async fn ft1();
| - type in trait
@ -197,7 +197,7 @@ LL | async fn ft1() {}
found fn pointer `fn() -> impl Future`
error[E0053]: method `ft5` has an incompatible type for trait
--> $DIR/fn-header-semantic-fail.rs:34:48
--> $DIR/fn-header-semantic-fail.rs:33:48
|
LL | const async unsafe extern "C" fn ft5();
| - type in trait

View File

@ -6,7 +6,7 @@
// run-pass
// compile-flags: -Z unleash-the-miri-inside-of-you
#![feature(core_intrinsics, const_caller_location, const_fn)]
#![feature(core_intrinsics, const_caller_location)]
type L = &'static std::panic::Location<'static>;

View File

@ -2,7 +2,7 @@
// revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=4
#![feature(const_caller_location, const_fn)]
#![feature(const_caller_location)]
use std::panic::Location;

View File

@ -1,4 +1,4 @@
#![feature(rustc_attrs, const_fn)]
#![feature(rustc_attrs)]
#[rustc_args_required_const(0)]
fn foo(_a: i32) {

View File

@ -1,6 +1,6 @@
// Various checks that stability attributes are used correctly, per RFC 507
#![feature(const_fn, staged_api)]
#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]

View File

@ -1,5 +1,3 @@
#![feature(const_fn)]
struct WithDtor;
impl Drop for WithDtor {

View File

@ -1,5 +1,5 @@
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:9:60
--> $DIR/static-drop-scope.rs:7:60
|
LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
| ^^^^^^^^- value is dropped here
@ -7,7 +7,7 @@ LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
| statics cannot evaluate destructors
error[E0716]: temporary value dropped while borrowed
--> $DIR/static-drop-scope.rs:9:60
--> $DIR/static-drop-scope.rs:7:60
|
LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
| ------^^^^^^^^-
@ -17,7 +17,7 @@ LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
| using this value as a static requires that borrow lasts for `'static`
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:13:59
--> $DIR/static-drop-scope.rs:11:59
|
LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
| ^^^^^^^^- value is dropped here
@ -25,7 +25,7 @@ LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
| constants cannot evaluate destructors
error[E0716]: temporary value dropped while borrowed
--> $DIR/static-drop-scope.rs:13:59
--> $DIR/static-drop-scope.rs:11:59
|
LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
| ------^^^^^^^^-
@ -35,7 +35,7 @@ LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
| using this value as a constant requires that borrow lasts for `'static`
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:17:28
--> $DIR/static-drop-scope.rs:15:28
|
LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
| ^^^^^^^^^^^^^ - value is dropped here
@ -43,7 +43,7 @@ LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
| statics cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:20:27
--> $DIR/static-drop-scope.rs:18:27
|
LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
| ^^^^^^^^^^^^^ - value is dropped here
@ -51,7 +51,7 @@ LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
| constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:23:24
--> $DIR/static-drop-scope.rs:21:24
|
LL | const fn const_drop<T>(_: T) {}
| ^ - value is dropped here
@ -59,7 +59,7 @@ LL | const fn const_drop<T>(_: T) {}
| constant functions cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:27:5
--> $DIR/static-drop-scope.rs:25:5
|
LL | (x, ()).1
| ^^^^^^^ constant functions cannot evaluate destructors
@ -68,7 +68,7 @@ LL | }
| - value is dropped here
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:31:34
--> $DIR/static-drop-scope.rs:29:34
|
LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
| ^^^^^^^^^^^^^^^^^^^ - value is dropped here
@ -76,7 +76,7 @@ LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
| constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/static-drop-scope.rs:36:43
--> $DIR/static-drop-scope.rs:34:43
|
LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
| ^^^^^^^^^^^ - value is dropped here

View File

@ -1,4 +1,4 @@
#![feature(const_fn, thread_local)]
#![feature(thread_local)]
#[thread_local]
static A: u32 = 1;

View File

@ -1,4 +1,4 @@
#![feature(cfg_target_thread_local, const_fn, thread_local)]
#![feature(cfg_target_thread_local, thread_local)]
#![crate_type = "lib"]
#[cfg(target_thread_local)]

View File

@ -1,4 +1,3 @@
#![feature(const_fn)]
#![feature(thread_local)]
#![feature(cfg_target_thread_local, thread_local_internals)]

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/issue-43733.rs:18:5
--> $DIR/issue-43733.rs:17:5
|
LL | __KEY.get(Default::default)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
@ -7,7 +7,7 @@ LL | __KEY.get(Default::default)
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/issue-43733.rs:22:5
--> $DIR/issue-43733.rs:21:5
|
LL | std::thread::LocalKey::new(__getit);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(const_fn)]
type Field1 = (i32, u32);
type Field2 = f32;
type Field3 = i64;

View File

@ -1,7 +1,6 @@
#![stable(feature = "foo", since = "1.33.0")]
#![feature(staged_api)]
#![feature(const_raw_ptr_deref)]
#![feature(const_fn)]
#[stable(feature = "foo", since = "1.33.0")]
#[rustc_const_unstable(feature = "const_foo", issue = "none")]

View File

@ -1,5 +1,5 @@
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
--> $DIR/unsafe-unstable-const-fn.rs:9:5
--> $DIR/unsafe-unstable-const-fn.rs:8:5
|
LL | *a == b
| ^^ dereference of raw pointer

View File

@ -1,4 +1,3 @@
#![feature(const_fn)]
#![allow(dead_code, clippy::missing_safety_doc)]
#![warn(clippy::new_without_default)]

View File

@ -1,5 +1,5 @@
error: you should consider adding a `Default` implementation for `Foo`
--> $DIR/new_without_default.rs:8:5
--> $DIR/new_without_default.rs:7:5
|
LL | / pub fn new() -> Foo {
LL | | Foo
@ -17,7 +17,7 @@ LL | }
|
error: you should consider adding a `Default` implementation for `Bar`
--> $DIR/new_without_default.rs:16:5
--> $DIR/new_without_default.rs:15:5
|
LL | / pub fn new() -> Self {
LL | | Bar
@ -34,7 +34,7 @@ LL | }
|
error: you should consider adding a `Default` implementation for `LtKo<'c>`
--> $DIR/new_without_default.rs:80:5
--> $DIR/new_without_default.rs:79:5
|
LL | / pub fn new() -> LtKo<'c> {
LL | | unimplemented!()
@ -51,7 +51,7 @@ LL | }
|
error: you should consider adding a `Default` implementation for `NewNotEqualToDerive`
--> $DIR/new_without_default.rs:157:5
--> $DIR/new_without_default.rs:156:5
|
LL | / pub fn new() -> Self {
LL | | NewNotEqualToDerive { foo: 1 }
@ -68,7 +68,7 @@ LL | }
|
error: you should consider adding a `Default` implementation for `FooGenerics<T>`
--> $DIR/new_without_default.rs:165:5
--> $DIR/new_without_default.rs:164:5
|
LL | / pub fn new() -> Self {
LL | | Self(Default::default())
@ -85,7 +85,7 @@ LL | }
|
error: you should consider adding a `Default` implementation for `BarGenerics<T>`
--> $DIR/new_without_default.rs:172:5
--> $DIR/new_without_default.rs:171:5
|
LL | / pub fn new() -> Self {
LL | | Self(Default::default())