-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
#[derive(Debug)] fails when a generic parameter shares the name of the generic type #97343
Copy link
Copy link
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.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.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.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.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected to see this happen:
Code should compile normally as expected, with a correct
fmt::Debugimplementation. Omitting the derive shows that rustc accepts this as valid and intelligible code. We know that rustc is interpreting the type ofirrelevantas the type parameter and not the parent struct, as the latter would produce an error since it would produce a recursive type with infinite size which would cause an error. As rustc defines the rust language, the derive macro should also handle this code correctly.Instead, this happened:
Compilation errors with the following diagnostic:
Meta
I tested this and got the same result on the following versions: