Skip to content

Commit

Permalink
add test case for implicitly stable const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jan 28, 2025
1 parent 4aaf467 commit d250657
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tests/ui/traits/const-traits/staged-api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,17 @@ const fn stable_const_context() {
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
}

const fn implicitly_stable_const_context() {
Unstable::func();
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
//~| ERROR cannot use `#[feature(unstable)]`
Foo::func();
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
//~| ERROR cannot use `#[feature(unstable)]`
const_context_not_const_stable();
//~^ ERROR cannot use `#[feature(local_feature)]`
conditionally_const::<Foo>();
//~^ ERROR cannot use `#[feature(const_trait_impl)]`
}

fn main() {}
105 changes: 104 additions & 1 deletion tests/ui/traits/const-traits/staged-api.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,108 @@ LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
LL | const fn stable_const_context() {
|

error: aborting due to 13 previous errors
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]`
--> $DIR/staged-api.rs:76:5
|
LL | Unstable::func();
| ^^^^^^^^^^^^^^^^
|
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)
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn implicitly_stable_const_context() {
|
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
LL | const fn implicitly_stable_const_context() {
|

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]`
--> $DIR/staged-api.rs:76:5
|
LL | Unstable::func();
| ^^^^^^^^^^^^^^^^
|
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)
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn implicitly_stable_const_context() {
|
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(unstable)]
LL | const fn implicitly_stable_const_context() {
|

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]`
--> $DIR/staged-api.rs:79:5
|
LL | Foo::func();
| ^^^^^^^^^^^
|
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)
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn implicitly_stable_const_context() {
|
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
LL | const fn implicitly_stable_const_context() {
|

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]`
--> $DIR/staged-api.rs:79:5
|
LL | Foo::func();
| ^^^^^^^^^^^
|
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)
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn implicitly_stable_const_context() {
|
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(unstable)]
LL | const fn implicitly_stable_const_context() {
|

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local_feature)]`
--> $DIR/staged-api.rs:82:5
|
LL | const_context_not_const_stable();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features
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)
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn implicitly_stable_const_context() {
|
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(local_feature)]
LL | const fn implicitly_stable_const_context() {
|

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]`
--> $DIR/staged-api.rs:84:5
|
LL | conditionally_const::<Foo>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
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)
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn implicitly_stable_const_context() {
|
help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(const_trait_impl)]
LL | const fn implicitly_stable_const_context() {
|

error: aborting due to 19 previous errors

0 comments on commit d250657

Please sign in to comment.