1 // revisions: stable unstable
3 #![cfg_attr(unstable, feature(unstable))] // The feature from the ./auxiliary/staged-api.rs file.
4 #![feature(const_trait_impl)]
5 #![feature(staged_api)]
6 #![stable(feature = "rust1", since = "1.0.0")]
8 // aux-build: staged-api.rs
9 extern crate staged_api;
13 #[stable(feature = "rust1", since = "1.0.0")]
16 #[stable(feature = "rust1", since = "1.0.0")]
17 #[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))]
18 #[cfg_attr(stable, rustc_const_stable(feature = "foo", since = "1.0.0"))]
19 impl const MyTrait for Foo {
20 //[stable]~^ ERROR trait implementations cannot be const stable yet
24 // Const stability has no impact on usage in non-const contexts.
25 fn non_const_context() {
30 #[unstable(feature = "none", issue = "none")]
31 const fn const_context() {
33 // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is
36 //[unstable]~^ ERROR not yet stable as a const fn
37 // ^ fails, because the `foo` feature is not active
40 #[stable(feature = "rust1", since = "1.0.0")]
41 #[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))]
42 pub const fn const_context_not_const_stable() {
43 //[stable]~^ ERROR function has missing const stability attribute
45 // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is
48 //[unstable]~^ ERROR not yet stable as a const fn
49 // ^ fails, because the `foo` feature is not active
52 #[stable(feature = "rust1", since = "1.0.0")]
53 #[rustc_const_stable(feature = "cheese", since = "1.0.0")]
54 const fn stable_const_context() {
56 //[unstable]~^ ERROR not yet stable as a const fn
58 //[unstable]~^ ERROR not yet stable as a const fn
59 const_context_not_const_stable()
60 //[unstable]~^ ERROR not yet stable as a const fn