Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Feb 19, 2020
1 parent 5f06ce2 commit 19801b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
Expand Up @@ -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() {}
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/stability.rs
Expand Up @@ -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;
Expand All @@ -29,5 +40,4 @@ pub const fn bar() -> Int {
Int(1i32) + Int(2i32)
}


fn main() {}
18 changes: 15 additions & 3 deletions src/test/ui/rfc-2632-const-trait-impl/stability.stderr
@@ -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`.

0 comments on commit 19801b1

Please sign in to comment.