about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgnzlbg <gonzalobg88@gmail.com>2019-09-21 16:09:38 +0200
committergnzlbg <gonzalobg88@gmail.com>2019-09-21 16:09:38 +0200
commitd4344969731e55bd0acaee4ad6962a85c8e0f27a (patch)
tree1b4a61abcac2d1c6ef53290c87b7ecdc69dbf8c1
parent9cf9030e1cc4c6231419f5e9f7a5bd42eb1f55c1 (diff)
downloadrust-d4344969731e55bd0acaee4ad6962a85c8e0f27a.tar.gz
rust-d4344969731e55bd0acaee4ad6962a85c8e0f27a.zip
remove feature
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs17
-rw-r--r--src/libsyntax/feature_gate/active.rs3
-rw-r--r--src/libsyntax_pos/symbol.rs1
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr.rs24
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr.stderr152
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr_fail.rs8
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr20
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs19
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr93
-rw-r--r--src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs11
-rw-r--r--src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr12
11 files changed, 261 insertions, 99 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 3842942d97f..60b88277715 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -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();
                     }
                 }
                 _ => {
diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs
index d1a17dc14bd..dd78777b569 100644
--- a/src/libsyntax/feature_gate/active.rs
+++ b/src/libsyntax/feature_gate/active.rs
@@ -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),
 
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index e6be8a2cb87..597ae83572c 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -198,7 +198,6 @@ symbols! {
         const_compare_raw_pointers,
         const_constructor,
         const_fn,
-        const_fn_ptr,
         const_fn_union,
         const_generics,
         const_indexing,
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.rs b/src/test/ui/consts/const-eval/const_fn_ptr.rs
index 1acb3d8ad10..498f801db81 100644
--- a/src/test/ui/consts/const-eval/const_fn_ptr.rs
+++ b/src/test/ui/consts/const-eval/const_fn_ptr.rs
@@ -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);
 }
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.stderr b/src/test/ui/consts/const-eval/const_fn_ptr.stderr
new file mode 100644
index 00000000000..41452ee59eb
--- /dev/null
+++ b/src/test/ui/consts/const-eval/const_fn_ptr.stderr
@@ -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
+
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs
index e8041e56c38..14bd6558e7f 100644
--- a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs
+++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs
@@ -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() {}
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr
deleted file mode 100644
index b7f3a74cc44..00000000000
--- a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr
+++ /dev/null
@@ -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 {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
index 66e01cae314..74c60f9a2a5 100644
--- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
+++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
@@ -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
 }
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
index 020889c2ca1..611cc5313c0 100644
--- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
+++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
@@ -1,28 +1,71 @@
-error: any use of this value will cause an error
-  --> $DIR/const_fn_ptr_fail2.rs:8: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);
-   | ---------------------------
-   |
-   = note: `#[deny(const_err)]` on by default
-
-error: any use of this value will cause an error
-  --> $DIR/const_fn_ptr_fail2.rs:8: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);
-   | --------------------------------
+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: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: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`.
diff --git a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs
deleted file mode 100644
index ea1ca05c31b..00000000000
--- a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs
+++ /dev/null
@@ -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
-}
diff --git a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr
deleted file mode 100644
index fe5956d06f2..00000000000
--- a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr
+++ /dev/null
@@ -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`.