You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #153894 - estebank:issue-129792, r=nnethercote
Point at unit structs on foreign crates in type errors when they are the pattern of a binding
Consts and unit structs in patterns can be confusing if they are mistaken for new bindings. We already provide some context for unit structs and consts that come from the current crate, we now also point at those from foreign crates, and we properly skip cases where the pattern has type parameters which can't be confused with a new binding. So not suggest making a new binding when other suggestions are already emitted, as the likelihood of the other suggestions being what the user intended is higher. Make new binding suggestion verbose.
Fix#129792.
```
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
|
8 - let percentage = 4i32;
8 + let other_percentage = 4i32;
|
```
0 commit comments