- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.