File tree Expand file tree Collapse file tree 3 files changed +6
-13
lines changed
compiler/rustc_builtin_macros/src/deriving/generic Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -1039,7 +1039,9 @@ impl<'a> MethodDef<'a> {
10391039 let span = trait_. span ;
10401040 let mut patterns = Vec :: new ( ) ;
10411041 for i in 0 ..self_args. len ( ) {
1042- let struct_path = cx. path ( span, vec ! [ type_ident] ) ;
1042+ // We could use `type_ident` instead of `Self`, but in the case of a type parameter
1043+ // shadowing the struct name, that causes a second, unnecessary E0578 error. #97343
1044+ let struct_path = cx. path ( span, vec ! [ Ident :: new( kw:: SelfUpper , type_ident. span) ] ) ;
10431045 let ( pat, ident_expr) = trait_. create_struct_pattern (
10441046 cx,
10451047 struct_path,
Original file line number Diff line number Diff line change 11use std:: fmt:: Debug ;
22
3- #[ derive( Debug ) ] //~ ERROR expected struct, variant or union type, found type parameter `Irrelevant`
3+ #[ derive( Debug ) ]
44pub struct Irrelevant < Irrelevant > { //~ ERROR type arguments are not allowed for this type
55 irrelevant : Irrelevant ,
66}
Original file line number Diff line number Diff line change 1- error[E0574]: expected struct, variant or union type, found type parameter `Irrelevant`
2- --> $DIR/issue-97343.rs:3:10
3- |
4- LL | #[derive(Debug)]
5- | ^^^^^ not a struct, variant or union type
6- |
7- = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
8-
91error[E0109]: type arguments are not allowed for this type
102 --> $DIR/issue-97343.rs:4:23
113 |
@@ -16,7 +8,6 @@ LL | pub struct Irrelevant<Irrelevant> {
168 |
179 = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
1810
19- error: aborting due to 2 previous errors
11+ error: aborting due to previous error
2012
21- Some errors have detailed explanations: E0109, E0574.
22- For more information about an error, try `rustc --explain E0109`.
13+ For more information about this error, try `rustc --explain E0109`.
You can’t perform that action at this time.
0 commit comments