From 19801b12c950f727a4e6938a87b0b2fdece73c07 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 18 Feb 2020 15:45:54 -0800 Subject: [PATCH] Update tests --- .../const-check-fns-in-const-impl.rs | 2 +- .../const-check-fns-in-const-impl.stderr | 2 +- .../ui/rfc-2632-const-trait-impl/stability.rs | 12 +++++++++++- .../rfc-2632-const-trait-impl/stability.stderr | 18 +++++++++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs index cad4f69033b2a..3278f35bad2b2 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs @@ -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() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr index 8c220dc44ab47..7fe3a9fd8522c 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr @@ -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 for more information = help: add `#![feature(const_fn)]` to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/stability.rs b/src/test/ui/rfc-2632-const-trait-impl/stability.rs index 36cfaff2ffad4..03a6fb51503b5 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/stability.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/stability.rs @@ -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() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/stability.stderr b/src/test/ui/rfc-2632-const-trait-impl/stability.stderr index ce3bada01e853..1ecff62955b99 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/stability.stderr +++ b/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 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 ::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 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`.