mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
39631fdac1
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. Make new binding suggestion verbose.
22 lines
586 B
Plaintext
22 lines
586 B
Plaintext
error[E0308]: mismatched types
|
|
--> $DIR/issue-33504.rs:7:13
|
|
|
|
|
LL | struct Test;
|
|
| ----------- unit struct defined here
|
|
...
|
|
LL | let Test = 1;
|
|
| ^^^^ - this expression has type `{integer}`
|
|
| |
|
|
| expected integer, found `Test`
|
|
| `Test` is interpreted as a unit struct, not a new binding
|
|
|
|
|
help: introduce a new binding instead
|
|
|
|
|
LL - let Test = 1;
|
|
LL + let other_test = 1;
|
|
|
|
|
|
|
error: aborting due to 1 previous error
|
|
|
|
For more information about this error, try `rustc --explain E0308`.
|