File tree 3 files changed +24
-1
lines changed
compiler/rustc_builtin_macros/src/deriving/generic
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1039,7 +1039,9 @@ impl<'a> MethodDef<'a> {
1039
1039
let span = trait_. span ;
1040
1040
let mut patterns = Vec :: new ( ) ;
1041
1041
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) ] ) ;
1043
1045
let ( pat, ident_expr) = trait_. create_struct_pattern (
1044
1046
cx,
1045
1047
struct_path,
Original file line number Diff line number Diff line change
1
+ use std:: fmt:: Debug ;
2
+
3
+ #[ derive( Debug ) ]
4
+ pub struct Irrelevant < Irrelevant > { //~ ERROR type arguments are not allowed for this type
5
+ irrelevant : Irrelevant ,
6
+ }
7
+
8
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0109]: type arguments are not allowed for this type
2
+ --> $DIR/issue-97343.rs:4:23
3
+ |
4
+ LL | #[derive(Debug)]
5
+ | ----- in this derive macro expansion
6
+ LL | pub struct Irrelevant<Irrelevant> {
7
+ | ^^^^^^^^^^ type argument not allowed
8
+ |
9
+ = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
10
+
11
+ error: aborting due to previous error
12
+
13
+ For more information about this error, try `rustc --explain E0109`.
You can’t perform that action at this time.
0 commit comments