Skip to content

Commit a84f90a

Browse files
committed
Update tests
1 parent fc9e5c4 commit a84f90a

File tree

7 files changed

+24
-20
lines changed

7 files changed

+24
-20
lines changed

tests/ui/consts/rustc-impl-const-stability.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub struct Data {
1212

1313
#[stable(feature = "potato", since = "1.27.0")]
1414
#[rustc_const_unstable(feature = "data_foo", issue = "none")]
15-
impl const Default for Data {
16-
fn default() -> Data {
17-
Data { _data: 42 }
15+
impl const std::fmt::Debug for Data {
16+
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
17+
panic!()
1818
}
1919
}

tests/ui/consts/rustc-impl-const-stability.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
1+
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
22
--> $DIR/rustc-impl-const-stability.rs:15:12
33
|
4-
LL | impl const Default for Data {
5-
| ^^^^^^^ this trait is not `const`
4+
LL | impl const std::fmt::Debug for Data {
5+
| ^^^^^^^^^^^^^^^ this trait is not `const`
66
|
77
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
88
= note: adding a non-const method body in the future would be a breaking change
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[derive_const(Debug)] //~ ERROR use of unstable library feature
22
//~^ ERROR const `impl` for trait `Debug` which is not marked with `#[const_trait]`
3-
//~| ERROR cannot call non-const method `Formatter::<'_>::write_str` in constant functions
3+
//~| ERROR cannot call non-const method
44
pub struct S;
55

66
fn main() {}

tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ impl Default for A {
77
fn default() -> A { A }
88
}
99

10-
#[derive_const(Default)]
10+
#[derive_const(Debug)]
1111
pub struct S(A);
1212

1313
fn main() {}
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
error[E0658]: use of unstable const library feature `const_default`
1+
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
22
--> $DIR/derive-const-non-const-type.rs:10:16
33
|
4-
LL | #[derive_const(Default)]
5-
| ^^^^^^^ trait is not stable as const yet
4+
LL | #[derive_const(Debug)]
5+
| ^^^^^ this trait is not `const`
66
|
7-
= help: add `#![feature(const_default)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
7+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
8+
= note: adding a non-const method body in the future would be a breaking change
99

10-
error[E0015]: cannot call non-const associated function `<A as Default>::default` in constant functions
10+
error[E0277]: `A` doesn't implement `Debug`
1111
--> $DIR/derive-const-non-const-type.rs:11:14
1212
|
13-
LL | #[derive_const(Default)]
14-
| ------- in this derive macro expansion
13+
LL | #[derive_const(Debug)]
14+
| ----- in this derive macro expansion
1515
LL | pub struct S(A);
16-
| ^
16+
| ^ the trait `Debug` is not implemented for `A`
17+
|
18+
= note: add `#[derive(Debug)]` to `A` or manually `impl Debug for A`
19+
help: consider annotating `A` with `#[derive(Debug)]`
20+
|
21+
LL + #[derive(Debug)]
22+
LL | pub struct A;
1723
|
18-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1924

2025
error: aborting due to 2 previous errors
2126

22-
Some errors have detailed explanations: E0015, E0658.
23-
For more information about an error, try `rustc --explain E0015`.
27+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)