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.
This commit is contained in:
commit
0804ef6563
@ -1039,7 +1039,9 @@ fn expand_struct_method_body<'b>(
|
||||
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,
|
||||
|
8
src/test/ui/derives/issue-97343.rs
Normal file
8
src/test/ui/derives/issue-97343.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Irrelevant<Irrelevant> { //~ ERROR type arguments are not allowed for this type
|
||||
irrelevant: Irrelevant,
|
||||
}
|
||||
|
||||
fn main() {}
|
13
src/test/ui/derives/issue-97343.stderr
Normal file
13
src/test/ui/derives/issue-97343.stderr
Normal file
@ -0,0 +1,13 @@
|
||||
error[E0109]: type arguments are not allowed for this type
|
||||
--> $DIR/issue-97343.rs:4:23
|
||||
|
|
||||
LL | #[derive(Debug)]
|
||||
| ----- in this derive macro expansion
|
||||
LL | pub struct Irrelevant<Irrelevant> {
|
||||
| ^^^^^^^^^^ type argument not allowed
|
||||
|
|
||||
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0109`.
|
Loading…
Reference in New Issue
Block a user