Fix up tests

This commit is contained in:
Oli Scherer 2022-05-19 14:48:39 +00:00
parent aa9eae50f3
commit f9c4f2b7ad
5 changed files with 83 additions and 4 deletions

View File

@ -0,0 +1,16 @@
// aux-build: staged-api.rs
extern crate staged_api;
use staged_api::*;
// Const stability has no impact on usage in non-const contexts.
fn non_const_context() {
Unstable::func();
}
const fn stable_const_context() {
Unstable::func();
//~^ ERROR cannot call non-const fn `<staged_api::Unstable as staged_api::MyTrait>::func` in constant functions
}
fn main() {}

View File

@ -0,0 +1,11 @@
error[E0015]: cannot call non-const fn `<staged_api::Unstable as staged_api::MyTrait>::func` in constant functions
--> $DIR/staged-api-user-crate.rs:12:5
|
LL | Unstable::func();
| ^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error
For more information about this error, try `rustc --explain E0015`.

View File

@ -33,15 +33,31 @@ const fn const_context() {
// ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is
// not const-stable.
Foo::func();
//[unstable]~^ not yet stable as a const fn
//[unstable]~^ ERROR not yet stable as a const fn
// ^ fails, because the `foo` feature is not active
}
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))]
pub const fn const_context_not_const_stable() {
//[stable]~^ ERROR function has missing const stability attribute
Unstable::func();
// ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is
// not const-stable.
Foo::func();
//[unstable]~^ ERROR not yet stable as a const fn
// ^ fails, because the `foo` feature is not active
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "cheese", since = "1.0.0")]
const fn stable_const_context() {
Unstable::func();
//[unstable]~^ ERROR not yet stable as a const fn
Foo::func();
//[unstable]~^ ERROR not yet stable as a const fn
const_context_not_const_stable()
//[unstable]~^ ERROR not yet stable as a const fn
}
fn main() {}

View File

@ -9,5 +9,17 @@ LL | | }
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
error: aborting due to previous error
error: function has missing const stability attribute
--> $DIR/staged-api.rs:42:1
|
LL | / pub const fn const_context_not_const_stable() {
LL | |
LL | | Unstable::func();
LL | | // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is
... |
LL | | // ^ fails, because the `foo` feature is not active
LL | | }
| |_^
error: aborting due to 2 previous errors

View File

@ -7,12 +7,36 @@ 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:43:5
--> $DIR/staged-api.rs:47:5
|
LL | Foo::func();
| ^^^^^^^^^^^
|
= help: add `#![feature(foo)]` to the crate attributes to enable
error: aborting due to 2 previous errors
error: `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
--> $DIR/staged-api.rs:55:5
|
LL | Unstable::func();
| ^^^^^^^^^^^^^^^^
|
= help: const-stable functions can only call other const-stable functions
error: `<Foo as staged_api::MyTrait>::func` is not yet stable as a const fn
--> $DIR/staged-api.rs:57:5
|
LL | Foo::func();
| ^^^^^^^^^^^
|
= help: const-stable functions can only call other const-stable functions
error: `const_context_not_const_stable` is not yet stable as a const fn
--> $DIR/staged-api.rs:59:5
|
LL | const_context_not_const_stable()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: const-stable functions can only call other const-stable functions
error: aborting due to 5 previous errors