Skip to content

Commit dba9c55

Browse files
committed
Fix test
1 parent 456b039 commit dba9c55

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
pub struct A;
55

6-
impl Default for A {
7-
fn default() -> A { A }
6+
impl std::fmt::Debug for A {
7+
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
8+
panic!()
9+
}
810
}
911

1012
#[derive_const(Debug)]
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
2-
--> $DIR/derive-const-non-const-type.rs:10:16
2+
--> $DIR/derive-const-non-const-type.rs:12:16
33
|
44
LL | #[derive_const(Debug)]
55
| ^^^^^ 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
99

10-
error[E0277]: `A` doesn't implement `Debug`
11-
--> $DIR/derive-const-non-const-type.rs:11:14
10+
error[E0015]: cannot call non-const method `Formatter::<'_>::debug_tuple_field1_finish` in constant functions
11+
--> $DIR/derive-const-non-const-type.rs:12:16
1212
|
1313
LL | #[derive_const(Debug)]
14-
| ----- in this derive macro expansion
15-
LL | pub struct S(A);
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;
14+
| ^^^^^
2315
|
16+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2417

2518
error: aborting due to 2 previous errors
2619

27-
For more information about this error, try `rustc --explain E0277`.
20+
For more information about this error, try `rustc --explain E0015`.

0 commit comments

Comments
 (0)