Closed
Description
Given the following code: https://play.rust-lang.org/?edition=2018&gist=5f8c9b8b72174c48746e236c827ab881
use std::fmt;
trait Trait {}
struct X<T>(T);
impl<T: fmt::Debug + Trait> fmt::Debug for X<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("X").field(&self.0).finish()
}
}
#[derive(Debug)]
struct Y<T>(X<T>);
The current output is:
error[E0277]: the trait bound `T: Trait` is not satisfied
--> src/lib.rs:14:13
|
14 | struct Y<T>(X<T>);
| ^^^^ the trait `Trait` is not implemented for `T`
|
= note: required because of the requirements on the impl of `Debug` for `X<T>`
= note: 1 redundant requirements hidden
= note: required because of the requirements on the impl of `Debug` for `&X<T>`
= note: required for the cast to the object type `dyn Debug`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting this bound
|
13 | #[derive(Debug + Trait)]
| ^^^^^^^
The proposed solution is obviously wrong, the compiler should suggest a manual impl instead.