From 1754825c24f51a1deec46a273b37c0fea32881f3 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 15 Dec 2023 14:04:35 -0800 Subject: [PATCH] Work around trivial bounds being unstable --- impl/src/expand.rs | 4 +++- tests/ui/union.stderr | 17 ----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/impl/src/expand.rs b/impl/src/expand.rs index 13c5fb3..4ce2c0b 100644 --- a/impl/src/expand.rs +++ b/impl/src/expand.rs @@ -38,7 +38,9 @@ fn fallback(input: &DeriveInput, error: syn::Error) -> TokenStream { #[allow(unused_qualifications)] impl #impl_generics std::error::Error for #ty #ty_generics #where_clause where - #ty #ty_generics: ::core::fmt::Debug, + // Work around trivial bounds being unstable. + // https://github.com/rust-lang/rust/issues/48214 + for<'workaround> #ty #ty_generics: ::core::fmt::Debug, {} #[allow(unused_qualifications)] diff --git a/tests/ui/union.stderr b/tests/ui/union.stderr index 8a07ae6..3ec4d71 100644 --- a/tests/ui/union.stderr +++ b/tests/ui/union.stderr @@ -6,20 +6,3 @@ error: union as errors are not supported 6 | | num: usize, 7 | | } | |_^ - -error[E0277]: `U` doesn't implement `Debug` - --> tests/ui/union.rs:3:10 - | -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` - = 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 { - |