Skip to content

Commit f1081ef

Browse files
committed
add test case for implicitly stable const fn
1 parent 9737061 commit f1081ef

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed

tests/ui/traits/const-traits/staged-api.rs

+13
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,17 @@ const fn stable_const_context() {
7272
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
7373
}
7474

75+
const fn implicitly_stable_const_context() {
76+
Unstable::func();
77+
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
78+
//~| ERROR cannot use `#[feature(unstable)]`
79+
Foo::func();
80+
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
81+
//~| ERROR cannot use `#[feature(unstable)]`
82+
const_context_not_const_stable();
83+
//~^ ERROR cannot use `#[feature(local_feature)]`
84+
conditionally_const::<Foo>();
85+
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
86+
}
87+
7588
fn main() {}

tests/ui/traits/const-traits/staged-api.stderr

+104-1
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,108 @@ LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
220220
LL | const fn stable_const_context() {
221221
|
222222

223-
error: aborting due to 13 previous errors
223+
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]`
224+
--> $DIR/staged-api.rs:76:5
225+
|
226+
LL | Unstable::func();
227+
| ^^^^^^^^^^^^^^^^
228+
|
229+
help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
230+
|
231+
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
232+
LL | const fn implicitly_stable_const_context() {
233+
|
234+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
235+
|
236+
LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
237+
LL | const fn implicitly_stable_const_context() {
238+
|
239+
240+
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]`
241+
--> $DIR/staged-api.rs:76:5
242+
|
243+
LL | Unstable::func();
244+
| ^^^^^^^^^^^^^^^^
245+
|
246+
help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
247+
|
248+
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
249+
LL | const fn implicitly_stable_const_context() {
250+
|
251+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
252+
|
253+
LL + #[rustc_allow_const_fn_unstable(unstable)]
254+
LL | const fn implicitly_stable_const_context() {
255+
|
256+
257+
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]`
258+
--> $DIR/staged-api.rs:79:5
259+
|
260+
LL | Foo::func();
261+
| ^^^^^^^^^^^
262+
|
263+
help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
264+
|
265+
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
266+
LL | const fn implicitly_stable_const_context() {
267+
|
268+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
269+
|
270+
LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
271+
LL | const fn implicitly_stable_const_context() {
272+
|
273+
274+
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]`
275+
--> $DIR/staged-api.rs:79:5
276+
|
277+
LL | Foo::func();
278+
| ^^^^^^^^^^^
279+
|
280+
help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
281+
|
282+
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
283+
LL | const fn implicitly_stable_const_context() {
284+
|
285+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
286+
|
287+
LL + #[rustc_allow_const_fn_unstable(unstable)]
288+
LL | const fn implicitly_stable_const_context() {
289+
|
290+
291+
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local_feature)]`
292+
--> $DIR/staged-api.rs:82:5
293+
|
294+
LL | const_context_not_const_stable();
295+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
296+
|
297+
= help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unsafe features
298+
help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
299+
|
300+
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
301+
LL | const fn implicitly_stable_const_context() {
302+
|
303+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
304+
|
305+
LL + #[rustc_allow_const_fn_unstable(local_feature)]
306+
LL | const fn implicitly_stable_const_context() {
307+
|
308+
309+
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]`
310+
--> $DIR/staged-api.rs:84:5
311+
|
312+
LL | conditionally_const::<Foo>();
313+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
314+
|
315+
help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
316+
|
317+
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
318+
LL | const fn implicitly_stable_const_context() {
319+
|
320+
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
321+
|
322+
LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
323+
LL | const fn implicitly_stable_const_context() {
324+
|
325+
326+
error: aborting due to 19 previous errors
224327

0 commit comments

Comments
 (0)