Skip to content

Point at unit structs in type errors when they are the pattern of a let binding #129792

Open

Description

We currently already do this when the unit struct is from the current crate:

error[E0308]: mismatched types
 --> fi.rs:8:9
  |
1 | struct percentage;
  | ----------------- unit struct defined here
...
8 |     let percentage = 4i32;
  |         ^^^^^^^^^^   ---- this expression has type `i32`
  |         |
  |         expected `i32`, found `percentage`
  |         `percentage` is interpreted as a unit struct, not a new binding
  |         help: introduce a new binding instead: `other_percentage`

but we must do that also when they come from other crates as well.

https://hachyderm.io/@LGUG2Z/113052067582966834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    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