File tree 3 files changed +6
-13
lines changed
compiler/rustc_builtin_macros/src/deriving/generic
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> {
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
1
use std:: fmt:: Debug ;
2
2
3
- #[ derive( Debug ) ] //~ ERROR expected struct, variant or union type, found type parameter `Irrelevant`
3
+ #[ derive( Debug ) ]
4
4
pub struct Irrelevant < Irrelevant > { //~ ERROR type arguments are not allowed for this type
5
5
irrelevant : Irrelevant ,
6
6
}
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
-
9
1
error[E0109]: type arguments are not allowed for this type
10
2
--> $DIR/issue-97343.rs:4:23
11
3
|
@@ -16,7 +8,6 @@ LL | pub struct Irrelevant<Irrelevant> {
16
8
|
17
9
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
18
10
19
- error: aborting due to 2 previous errors
11
+ error: aborting due to previous error
20
12
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