Skip to content

Point at type parameter shadowing another type in E0574 #97459

Closed
@estebank

Description

@estebank

When a type parameter shadows a type name in a pattern, E0574 should point at the type parameter and check if there are other types that could be resolved with the same name and point at them as well.

It currently is

error[E0574]: expected struct, variant or union type, found type parameter `Irrelevant`
  --> src/lib.rs:10:13
   |
10 |             Irrelevant { irrelevant } => {
   |             ^^^^^^^^^^ not a struct, variant or union type

and should be

error[E0574]: expected struct, variant or union type, found type parameter `Irrelevant`
  --> src/lib.rs:10:13
   | 
 3 | pub struct Irrelevant<Irrelevant> {
   |            ---------- you might have meant to refer to this struct
...     
 7 |   impl<Irrelevant: Debug> Debug for Irrelevant<Irrelevant> {
   |        ---------- found this type parameter
...
10 |             Irrelevant { irrelevant } => {
   |             ^^^^^^^^^^ not a struct, variant or union type

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions