about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-05-28 01:11:50 +0200
committerGitHub <noreply@github.com>2022-05-28 01:11:50 +0200
commit0804ef656399d4a31e9aa07c34a64d7628320880 (patch)
treed63660b6603ccf15e7d42d8f7f01a7f026d5c4db /compiler/rustc_builtin_macros/src
parent29ac9b13d48205d1c5caec1d0b40cf8bc7f9fa41 (diff)
parentf2a1b7b7724fef2876094f9b4a6c356345d7dd67 (diff)
downloadrust-0804ef656399d4a31e9aa07c34a64d7628320880.tar.gz
rust-0804ef656399d4a31e9aa07c34a64d7628320880.zip
Rollup merge of #97458 - estebank:use-self-in-derive-macro, r=compiler-errors
Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error

Reduce verbosity in #97343.
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/generic/mod.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
index 0832fdad8b8..53369afae27 100644
--- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
@@ -1039,7 +1039,9 @@ impl<'a> MethodDef<'a> {
         let span = trait_.span;
         let mut patterns = Vec::new();
         for i in 0..self_args.len() {
-            let struct_path = cx.path(span, vec![type_ident]);
+            // We could use `type_ident` instead of `Self`, but in the case of a type parameter
+            // shadowing the struct name, that causes a second, unnecessary E0578 error. #97343
+            let struct_path = cx.path(span, vec![Ident::new(kw::SelfUpper, type_ident.span)]);
             let (pat, ident_expr) = trait_.create_struct_pattern(
                 cx,
                 struct_path,