Skip to content

Commit

Permalink
Try to remove "doesn't implement Debug" in fallback expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 15, 2023
1 parent d7e3bdd commit 1567f40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 4 additions & 1 deletion impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ fn fallback(input: &DeriveInput, error: syn::Error) -> TokenStream {
#error

#[allow(unused_qualifications)]
impl #impl_generics std::error::Error for #ty #ty_generics #where_clause {}
impl #impl_generics std::error::Error for #ty #ty_generics #where_clause
where
#ty #ty_generics: ::core::fmt::Debug,
{}

#[allow(unused_qualifications)]
impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause {
Expand Down
20 changes: 9 additions & 11 deletions tests/ui/union.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ error: union as errors are not supported
| |_^

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

0 comments on commit 1567f40

Please sign in to comment.