Skip to content

Commit 1567f40

Browse files
committed
Try to remove "doesn't implement Debug" in fallback expansion
1 parent d7e3bdd commit 1567f40

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

impl/src/expand.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ fn fallback(input: &DeriveInput, error: syn::Error) -> TokenStream {
3636
#error
3737

3838
#[allow(unused_qualifications)]
39-
impl #impl_generics std::error::Error for #ty #ty_generics #where_clause {}
39+
impl #impl_generics std::error::Error for #ty #ty_generics #where_clause
40+
where
41+
#ty #ty_generics: ::core::fmt::Debug,
42+
{}
4043

4144
#[allow(unused_qualifications)]
4245
impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause {

tests/ui/union.stderr

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ error: union as errors are not supported
88
| |_^
99

1010
error[E0277]: `U` doesn't implement `Debug`
11-
--> tests/ui/union.rs:4:11
11+
--> tests/ui/union.rs:3:10
1212
|
13-
4 | pub union U {
14-
| ^ `U` cannot be formatted using `{:?}`
13+
3 | #[derive(Error)]
14+
| ^^^^^ `U` cannot be formatted using `{:?}`
1515
|
1616
= help: the trait `Debug` is not implemented for `U`
1717
= note: add `#[derive(Debug)]` to `U` or manually `impl Debug for U`
18-
note: required by a bound in `std::error::Error`
19-
--> $RUST/core/src/error.rs
20-
|
21-
| pub trait Error: Debug + Display {
22-
| ^^^^^ required by this bound in `Error`
18+
= help: see issue #48214
19+
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
20+
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
2321
help: consider annotating `U` with `#[derive(Debug)]`
2422
|
25-
4 + #[derive(Debug)]
26-
5 | pub union U {
27-
|
23+
4 + #[derive(Debug)]
24+
5 | pub union U {
25+
|

0 commit comments

Comments
 (0)