Skip to content

Commit 19801b1

Browse files
Update tests
1 parent 5f06ce2 commit 19801b1

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn non_const() {}
1010

1111
impl const T for S {
1212
fn foo() { non_const() }
13-
//~^ ERROR
13+
//~^ ERROR can only call other `const fn`
1414
}
1515

1616
fn main() {}

src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr

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

1010
error: aborting due to previous error

src/test/ui/rfc-2632-const-trait-impl/stability.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77
pub struct Int(i32);
88

9+
#[stable(feature = "rust1", since = "1.0.0")]
10+
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
11+
impl const std::ops::Sub for Int {
12+
type Output = Self;
13+
14+
fn sub(self, rhs: Self) -> Self {
15+
//~^ ERROR trait methods cannot be stable const fn
16+
Int(self.0 - rhs.0)
17+
}
18+
}
19+
920
#[rustc_const_unstable(feature = "const_add", issue = "none")]
1021
impl const std::ops::Add for Int {
1122
type Output = Self;
@@ -29,5 +40,4 @@ pub const fn bar() -> Int {
2940
Int(1i32) + Int(2i32)
3041
}
3142

32-
3343
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
error[E0723]: trait methods cannot be stable const fn
2+
--> $DIR/stability.rs:14:5
3+
|
4+
LL | / fn sub(self, rhs: Self) -> Self {
5+
LL | |
6+
LL | | Int(self.0 - rhs.0)
7+
LL | | }
8+
| |_____^
9+
|
10+
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
11+
= help: add `#![feature(const_fn)]` to the crate attributes to enable
12+
113
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`
2-
--> $DIR/stability.rs:21:5
14+
--> $DIR/stability.rs:32:5
315
|
416
LL | Int(1i32) + Int(2i32)
517
| ^^^^^^^^^^^^^^^^^^^^^
618
|
7-
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
19+
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
820
= help: add `#![feature(const_fn)]` to the crate attributes to enable
921

10-
error: aborting due to previous error
22+
error: aborting due to 2 previous errors
1123

1224
For more information about this error, try `rustc --explain E0723`.

0 commit comments

Comments
 (0)