1
Fork 0

Update tests

This commit is contained in:
Dylan MacKenzie 2020-02-18 15:45:54 -08:00
parent 5f06ce2c0f
commit 19801b12c9
4 changed files with 28 additions and 6 deletions

View file

@ -10,7 +10,7 @@ fn non_const() {}
impl const T for S {
fn foo() { non_const() }
//~^ ERROR
//~^ ERROR can only call other `const fn`
}
fn main() {}

View file

@ -4,7 +4,7 @@ error[E0723]: can only call other `const fn` within a `const fn`, but `const non
LL | fn foo() { non_const() }
| ^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to previous error

View file

@ -6,6 +6,17 @@
pub struct Int(i32);
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
impl const std::ops::Sub for Int {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
//~^ ERROR trait methods cannot be stable const fn
Int(self.0 - rhs.0)
}
}
#[rustc_const_unstable(feature = "const_add", issue = "none")]
impl const std::ops::Add for Int {
type Output = Self;
@ -29,5 +40,4 @@ pub const fn bar() -> Int {
Int(1i32) + Int(2i32)
}
fn main() {}

View file

@ -1,12 +1,24 @@
error[E0723]: trait methods cannot be stable const fn
--> $DIR/stability.rs:14:5
|
LL | / fn sub(self, rhs: Self) -> Self {
LL | |
LL | | Int(self.0 - rhs.0)
LL | | }
| |_____^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: can only call other `const fn` within a `const fn`, but `const <Int as std::ops::Add>::add` is not stable as `const fn`
--> $DIR/stability.rs:21:5
--> $DIR/stability.rs:32:5
|
LL | Int(1i32) + Int(2i32)
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0723`.