Skip to content

Commit d434496

Browse files
committed
remove feature
1 parent 9cf9030 commit d434496

11 files changed

+261
-99
lines changed

src/librustc_mir/transform/qualify_consts.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1413,17 +1413,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
14131413
.opts
14141414
.debugging_opts
14151415
.unleash_the_miri_inside_of_you;
1416-
let const_fn_ptr = self.tcx.features().const_fn_ptr;
1417-
if self.mode.requires_const_checking() {
1418-
if !(unleash_miri || const_fn_ptr) {
1419-
emit_feature_err(
1420-
&self.tcx.sess.parse_sess,
1421-
sym::const_fn_ptr,
1422-
self.span,
1423-
GateIssue::Language,
1424-
"function pointers in const fn are unstable",
1425-
);
1426-
}
1416+
if self.mode.requires_const_checking() && !unleash_miri {
1417+
let mut err = self.tcx.sess.struct_span_err(
1418+
self.span,
1419+
"function pointers in `const fn` are unstable",
1420+
);
1421+
err.emit();
14271422
}
14281423
}
14291424
_ => {

src/libsyntax/feature_gate/active.rs

-3
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,6 @@ declare_features! (
405405
/// Allows macro invocations in `extern {}` blocks.
406406
(active, macros_in_extern, "1.27.0", Some(49476), None),
407407

408-
/// Allows calling function pointers inside `const` functions.
409-
(active, const_fn_ptr, "1.27.0", Some(51909), None),
410-
411408
/// Allows accessing fields of unions inside `const` functions.
412409
(active, const_fn_union, "1.27.0", Some(51909), None),
413410

src/libsyntax_pos/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ symbols! {
198198
const_compare_raw_pointers,
199199
const_constructor,
200200
const_fn,
201-
const_fn_ptr,
202201
const_fn_union,
203202
const_generics,
204203
const_indexing,
+20-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
// run-pass
2+
// compile-flags: -Zunleash-the-miri-inside-of-you
23
#![feature(const_fn)]
3-
#![feature(const_fn_ptr)]
44

5-
const fn double(x: usize) -> usize { x * 2 }
5+
fn double(x: usize) -> usize { x * 2 }
6+
const fn double_const(x: usize) -> usize { x * 2 }
7+
68
const X: fn(usize) -> usize = double;
9+
const X_const: fn(usize) -> usize = double_const;
710

811
const fn bar(x: usize) -> usize {
912
X(x)
1013
}
1114

15+
const fn bar_const(x: usize) -> usize {
16+
X_const(x)
17+
}
18+
1219
const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
1320
x(y)
1421
}
1522

1623
fn main() {
17-
const Y: usize = bar(2);
24+
const Y: usize = bar_const(2);
1825
assert_eq!(Y, 4);
19-
const Z: usize = foo(double, 2);
26+
let y = bar_const(2);
27+
assert_eq!(y, 4);
28+
let y = bar(2);
29+
assert_eq!(y, 4);
30+
31+
const Z: usize = foo(double_const, 2);
2032
assert_eq!(Z, 4);
33+
let z = foo(double_const, 2);
34+
assert_eq!(z, 4);
35+
let z = foo(double, 2);
36+
assert_eq!(z, 4);
2137
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
warning: skipping const checks
2+
--> $DIR/const_fn_ptr.rs:25:5
3+
|
4+
LL | assert_eq!(Y, 4);
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
8+
9+
warning: skipping const checks
10+
--> $DIR/const_fn_ptr.rs:25:5
11+
|
12+
LL | assert_eq!(Y, 4);
13+
| ^^^^^^^^^^^^^^^^^
14+
|
15+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
16+
17+
warning: skipping const checks
18+
--> $DIR/const_fn_ptr.rs:25:5
19+
|
20+
LL | assert_eq!(Y, 4);
21+
| ^^^^^^^^^^^^^^^^^
22+
|
23+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
24+
25+
warning: skipping const checks
26+
--> $DIR/const_fn_ptr.rs:27:5
27+
|
28+
LL | assert_eq!(y, 4);
29+
| ^^^^^^^^^^^^^^^^^
30+
|
31+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
32+
33+
warning: skipping const checks
34+
--> $DIR/const_fn_ptr.rs:27:5
35+
|
36+
LL | assert_eq!(y, 4);
37+
| ^^^^^^^^^^^^^^^^^
38+
|
39+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
40+
41+
warning: skipping const checks
42+
--> $DIR/const_fn_ptr.rs:27:5
43+
|
44+
LL | assert_eq!(y, 4);
45+
| ^^^^^^^^^^^^^^^^^
46+
|
47+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
48+
49+
warning: skipping const checks
50+
--> $DIR/const_fn_ptr.rs:29:5
51+
|
52+
LL | assert_eq!(y, 4);
53+
| ^^^^^^^^^^^^^^^^^
54+
|
55+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
56+
57+
warning: skipping const checks
58+
--> $DIR/const_fn_ptr.rs:29:5
59+
|
60+
LL | assert_eq!(y, 4);
61+
| ^^^^^^^^^^^^^^^^^
62+
|
63+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
64+
65+
warning: skipping const checks
66+
--> $DIR/const_fn_ptr.rs:29:5
67+
|
68+
LL | assert_eq!(y, 4);
69+
| ^^^^^^^^^^^^^^^^^
70+
|
71+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
72+
73+
warning: skipping const checks
74+
--> $DIR/const_fn_ptr.rs:32:5
75+
|
76+
LL | assert_eq!(Z, 4);
77+
| ^^^^^^^^^^^^^^^^^
78+
|
79+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
80+
81+
warning: skipping const checks
82+
--> $DIR/const_fn_ptr.rs:32:5
83+
|
84+
LL | assert_eq!(Z, 4);
85+
| ^^^^^^^^^^^^^^^^^
86+
|
87+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
88+
89+
warning: skipping const checks
90+
--> $DIR/const_fn_ptr.rs:32:5
91+
|
92+
LL | assert_eq!(Z, 4);
93+
| ^^^^^^^^^^^^^^^^^
94+
|
95+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
96+
97+
warning: skipping const checks
98+
--> $DIR/const_fn_ptr.rs:34:5
99+
|
100+
LL | assert_eq!(z, 4);
101+
| ^^^^^^^^^^^^^^^^^
102+
|
103+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
104+
105+
warning: skipping const checks
106+
--> $DIR/const_fn_ptr.rs:34:5
107+
|
108+
LL | assert_eq!(z, 4);
109+
| ^^^^^^^^^^^^^^^^^
110+
|
111+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
112+
113+
warning: skipping const checks
114+
--> $DIR/const_fn_ptr.rs:34:5
115+
|
116+
LL | assert_eq!(z, 4);
117+
| ^^^^^^^^^^^^^^^^^
118+
|
119+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
120+
121+
warning: skipping const checks
122+
--> $DIR/const_fn_ptr.rs:36:5
123+
|
124+
LL | assert_eq!(z, 4);
125+
| ^^^^^^^^^^^^^^^^^
126+
|
127+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
128+
129+
warning: skipping const checks
130+
--> $DIR/const_fn_ptr.rs:36:5
131+
|
132+
LL | assert_eq!(z, 4);
133+
| ^^^^^^^^^^^^^^^^^
134+
|
135+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
136+
137+
warning: skipping const checks
138+
--> $DIR/const_fn_ptr.rs:36:5
139+
|
140+
LL | assert_eq!(z, 4);
141+
| ^^^^^^^^^^^^^^^^^
142+
|
143+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
144+
145+
warning: constant `X_const` should have an upper case name
146+
--> $DIR/const_fn_ptr.rs:9:7
147+
|
148+
LL | const X_const: fn(usize) -> usize = double_const;
149+
| ^^^^^^^ help: convert the identifier to upper case: `X_CONST`
150+
|
151+
= note: `#[warn(non_upper_case_globals)]` on by default
152+
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// run-pass
2-
3-
// FIXME: this should not pass
4-
2+
// compile-flags: -Zunleash-the-miri-inside-of-you
53
#![feature(const_fn)]
6-
#![feature(const_fn_ptr)]
4+
#![allow(unused)]
75

86
fn double(x: usize) -> usize { x * 2 }
97
const X: fn(usize) -> usize = double;
108

119
const fn bar(x: usize) -> usize {
12-
X(x)
10+
X(x) // FIXME: this should error someday
1311
}
1412

1513
fn main() {}

src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr

-20
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
// compile-flags: -Zunleash-the-miri-inside-of-you
12
#![feature(const_fn)]
2-
#![feature(const_fn_ptr)]
3+
#![allow(const_err)]
34

45
fn double(x: usize) -> usize { x * 2 }
56
const X: fn(usize) -> usize = double;
@@ -8,14 +9,18 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
89
x(y)
910
}
1011

11-
const Y: usize = bar(X, 2);
12-
//~^ ERROR any use of this value will cause an error
13-
14-
const Z: usize = bar(double, 2);
15-
//~^ ERROR any use of this value will cause an error
16-
12+
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
13+
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
1714

1815
fn main() {
1916
assert_eq!(Y, 4);
17+
//~^ ERROR evaluation of constant expression failed
18+
//~^^ WARN skipping const checks
19+
//~^^^ WARN skipping const checks
20+
//~^^^^ WARN skipping const checks
2021
assert_eq!(Z, 4);
22+
//~^ ERROR evaluation of constant expression failed
23+
//~^^ WARN skipping const checks
24+
//~^^^ WARN skipping const checks
25+
//~^^^^ WARN skipping const checks
2126
}

0 commit comments

Comments
 (0)