remove feature
This commit is contained in:
parent
9cf9030e1c
commit
d434496973
@ -1413,17 +1413,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||
.opts
|
||||
.debugging_opts
|
||||
.unleash_the_miri_inside_of_you;
|
||||
let const_fn_ptr = self.tcx.features().const_fn_ptr;
|
||||
if self.mode.requires_const_checking() {
|
||||
if !(unleash_miri || const_fn_ptr) {
|
||||
emit_feature_err(
|
||||
&self.tcx.sess.parse_sess,
|
||||
sym::const_fn_ptr,
|
||||
self.span,
|
||||
GateIssue::Language,
|
||||
"function pointers in const fn are unstable",
|
||||
);
|
||||
}
|
||||
if self.mode.requires_const_checking() && !unleash_miri {
|
||||
let mut err = self.tcx.sess.struct_span_err(
|
||||
self.span,
|
||||
"function pointers in `const fn` are unstable",
|
||||
);
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
@ -405,9 +405,6 @@ declare_features! (
|
||||
/// Allows macro invocations in `extern {}` blocks.
|
||||
(active, macros_in_extern, "1.27.0", Some(49476), None),
|
||||
|
||||
/// Allows calling function pointers inside `const` functions.
|
||||
(active, const_fn_ptr, "1.27.0", Some(51909), None),
|
||||
|
||||
/// Allows accessing fields of unions inside `const` functions.
|
||||
(active, const_fn_union, "1.27.0", Some(51909), None),
|
||||
|
||||
|
@ -198,7 +198,6 @@ symbols! {
|
||||
const_compare_raw_pointers,
|
||||
const_constructor,
|
||||
const_fn,
|
||||
const_fn_ptr,
|
||||
const_fn_union,
|
||||
const_generics,
|
||||
const_indexing,
|
||||
|
@ -1,21 +1,37 @@
|
||||
// run-pass
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_fn_ptr)]
|
||||
|
||||
const fn double(x: usize) -> usize { x * 2 }
|
||||
fn double(x: usize) -> usize { x * 2 }
|
||||
const fn double_const(x: usize) -> usize { x * 2 }
|
||||
|
||||
const X: fn(usize) -> usize = double;
|
||||
const X_const: fn(usize) -> usize = double_const;
|
||||
|
||||
const fn bar(x: usize) -> usize {
|
||||
X(x)
|
||||
}
|
||||
|
||||
const fn bar_const(x: usize) -> usize {
|
||||
X_const(x)
|
||||
}
|
||||
|
||||
const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
|
||||
x(y)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
const Y: usize = bar(2);
|
||||
const Y: usize = bar_const(2);
|
||||
assert_eq!(Y, 4);
|
||||
const Z: usize = foo(double, 2);
|
||||
let y = bar_const(2);
|
||||
assert_eq!(y, 4);
|
||||
let y = bar(2);
|
||||
assert_eq!(y, 4);
|
||||
|
||||
const Z: usize = foo(double_const, 2);
|
||||
assert_eq!(Z, 4);
|
||||
let z = foo(double_const, 2);
|
||||
assert_eq!(z, 4);
|
||||
let z = foo(double, 2);
|
||||
assert_eq!(z, 4);
|
||||
}
|
||||
|
152
src/test/ui/consts/const-eval/const_fn_ptr.stderr
Normal file
152
src/test/ui/consts/const-eval/const_fn_ptr.stderr
Normal file
@ -0,0 +1,152 @@
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:25:5
|
||||
|
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:25:5
|
||||
|
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:25:5
|
||||
|
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:27:5
|
||||
|
|
||||
LL | assert_eq!(y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:27:5
|
||||
|
|
||||
LL | assert_eq!(y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:27:5
|
||||
|
|
||||
LL | assert_eq!(y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:29:5
|
||||
|
|
||||
LL | assert_eq!(y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:29:5
|
||||
|
|
||||
LL | assert_eq!(y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:29:5
|
||||
|
|
||||
LL | assert_eq!(y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:32:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:32:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:32:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:34:5
|
||||
|
|
||||
LL | assert_eq!(z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:34:5
|
||||
|
|
||||
LL | assert_eq!(z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:34:5
|
||||
|
|
||||
LL | assert_eq!(z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:36:5
|
||||
|
|
||||
LL | assert_eq!(z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:36:5
|
||||
|
|
||||
LL | assert_eq!(z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr.rs:36:5
|
||||
|
|
||||
LL | assert_eq!(z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: constant `X_const` should have an upper case name
|
||||
--> $DIR/const_fn_ptr.rs:9:7
|
||||
|
|
||||
LL | const X_const: fn(usize) -> usize = double_const;
|
||||
| ^^^^^^^ help: convert the identifier to upper case: `X_CONST`
|
||||
|
|
||||
= note: `#[warn(non_upper_case_globals)]` on by default
|
||||
|
@ -1,15 +1,13 @@
|
||||
// run-pass
|
||||
|
||||
// FIXME: this should not pass
|
||||
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_fn_ptr)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn double(x: usize) -> usize { x * 2 }
|
||||
const X: fn(usize) -> usize = double;
|
||||
|
||||
const fn bar(x: usize) -> usize {
|
||||
X(x)
|
||||
X(x) // FIXME: this should error someday
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,20 +0,0 @@
|
||||
warning: function is never used: `double`
|
||||
--> $DIR/const_fn_ptr_fail.rs:8:1
|
||||
|
|
||||
LL | fn double(x: usize) -> usize { x * 2 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: constant item is never used: `X`
|
||||
--> $DIR/const_fn_ptr_fail.rs:9:1
|
||||
|
|
||||
LL | const X: fn(usize) -> usize = double;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: function is never used: `bar`
|
||||
--> $DIR/const_fn_ptr_fail.rs:11:1
|
||||
|
|
||||
LL | const fn bar(x: usize) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,5 +1,6 @@
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_fn_ptr)]
|
||||
#![allow(const_err)]
|
||||
|
||||
fn double(x: usize) -> usize { x * 2 }
|
||||
const X: fn(usize) -> usize = double;
|
||||
@ -8,14 +9,18 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
|
||||
x(y)
|
||||
}
|
||||
|
||||
const Y: usize = bar(X, 2);
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Z: usize = bar(double, 2);
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
|
||||
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
|
||||
|
||||
fn main() {
|
||||
assert_eq!(Y, 4);
|
||||
//~^ ERROR evaluation of constant expression failed
|
||||
//~^^ WARN skipping const checks
|
||||
//~^^^ WARN skipping const checks
|
||||
//~^^^^ WARN skipping const checks
|
||||
assert_eq!(Z, 4);
|
||||
//~^ ERROR evaluation of constant expression failed
|
||||
//~^^ WARN skipping const checks
|
||||
//~^^^ WARN skipping const checks
|
||||
//~^^^^ WARN skipping const checks
|
||||
}
|
||||
|
@ -1,28 +1,71 @@
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_fn_ptr_fail2.rs:8:5
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:16:5
|
||||
|
|
||||
LL | x(y)
|
||||
| ^^^^
|
||||
| |
|
||||
| calling non-const function `double`
|
||||
| inside call to `bar` at $DIR/const_fn_ptr_fail2.rs:11:18
|
||||
...
|
||||
LL | const Y: usize = bar(X, 2);
|
||||
| ---------------------------
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_fn_ptr_fail2.rs:8:5
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:16:5
|
||||
|
|
||||
LL | x(y)
|
||||
| ^^^^
|
||||
| |
|
||||
| calling non-const function `double`
|
||||
| inside call to `bar` at $DIR/const_fn_ptr_fail2.rs:14:18
|
||||
...
|
||||
LL | const Z: usize = bar(double, 2);
|
||||
| --------------------------------
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:16:5
|
||||
|
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:21:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:21:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:21:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/const_fn_ptr_fail2.rs:16:5
|
||||
|
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^-^^^^^
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/const_fn_ptr_fail2.rs:21:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^-^^^^^
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
@ -1,11 +0,0 @@
|
||||
#![feature(const_fn)]
|
||||
|
||||
fn main() {}
|
||||
|
||||
const fn foo() {}
|
||||
const X: fn() = foo;
|
||||
|
||||
const fn bar() {
|
||||
X()
|
||||
//~^ ERROR function pointers in const fn are unstable
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
error[E0658]: function pointers in const fn are unstable
|
||||
--> $DIR/feature-gate-const_fn_ptr.rs:9:5
|
||||
|
|
||||
LL | X()
|
||||
| ^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/51909
|
||||
= help: add `#![feature(const_fn_ptr)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
Loading…
x
Reference in New Issue
Block a user