Try to remove "doesn't implement Debug" in fallback expansion

This commit is contained in:
David Tolnay 2023-12-15 14:03:15 -08:00
parent d7e3bdd980
commit 1567f40ec3
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 13 additions and 12 deletions

View File

@ -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 {

View File

@ -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 {
|