Skip to content

Implement proper stability check for const impl Trait, fall back to unstable const when undeclared #97177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stable const things need a stability attribute
  • Loading branch information
oli-obk committed May 19, 2022
commit aa9eae50f3fd6e4cc7ed0a3e8c2c2a24012e3564
1 change: 1 addition & 0 deletions src/test/ui/rfc-2632-const-trait-impl/staged-api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Foo;

#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))]
#[cfg_attr(stable, rustc_const_stable(feature = "foo", since = "1.0.0"))]
impl const MyTrait for Foo {
//[stable]~^ ERROR trait implementations cannot be const stable yet
fn func() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
error: implementation has missing const stability attribute
--> $DIR/staged-api.rs:18:1
error: trait implementations cannot be const stable yet
--> $DIR/staged-api.rs:19:1
|
LL | / impl const MyTrait for Foo {
LL | |
LL | | fn func() {}
LL | | }
| |_^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: `<Foo as staged_api::MyTrait>::func` is not yet stable as a const fn
--> $DIR/staged-api.rs:34:5
--> $DIR/staged-api.rs:35:5
|
LL | Foo::func();
| ^^^^^^^^^^^
|
= help: add `#![feature(foo)]` to the crate attributes to enable

error: `<Foo as staged_api::MyTrait>::func` is not yet stable as a const fn
--> $DIR/staged-api.rs:42:5
--> $DIR/staged-api.rs:43:5
|
LL | Foo::func();
| ^^^^^^^^^^^
Expand Down