Rollup merge of #67741 - estebank:point-at-pat-def, r=Centril
When encountering an Item in a pat context, point at the item def
```
error[E0308]: mismatched types
--> $DIR/const-in-struct-pat.rs:8:17
|
LL | struct foo;
| ----------- `foo` defined here
...
LL | let Thing { foo } = t;
| ^^^ expected struct `std::string::String`, found struct `foo`
|
= note: `foo` is interpreted as a unit struct, not a new binding
help: you can bind the struct field to a different name
|
LL | let Thing { foo: other_foo } = t;
| ^^^^^^^^^^^^^^
```
```
error[E0308]: mismatched types
--> $DIR/const.rs:14:9
|
LL | const FOO: Foo = Foo{bar: 5};
| ----------------------------- constant defined here
...
LL | FOO => {},
| ^^^
| |
| expected `&Foo`, found struct `Foo`
| `FOO` is interpreted as a constant, not a new binding
| help: use different name to introduce a new binding: `other_foo`
```
Fix #55631, fix #48062, cc #42876.
This commit is contained in:
commit
e8bb6c05ab
10 changed files with 147 additions and 28 deletions
|
|
@ -1,8 +1,15 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-33504.rs:7:13
|
||||
|
|
||||
LL | struct Test;
|
||||
| ------------ unit struct defined here
|
||||
...
|
||||
LL | let Test = 1;
|
||||
| ^^^^ expected integer, found struct `Test`
|
||||
| ^^^^
|
||||
| |
|
||||
| expected integer, found struct `Test`
|
||||
| `Test` is interpreted as a unit struct, not a new binding
|
||||
| help: introduce a new binding instead: `other_test`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-4968.rs:5:16
|
||||
|
|
||||
LL | const A: (isize,isize) = (4,2);
|
||||
| ------------------------------- constant defined here
|
||||
LL | fn main() {
|
||||
LL | match 42 { A => () }
|
||||
| ^ expected integer, found tuple
|
||||
| ^
|
||||
| |
|
||||
| expected integer, found tuple
|
||||
| `A` is interpreted as a constant, not a new binding
|
||||
| help: introduce a new binding instead: `other_a`
|
||||
|
|
||||
= note: expected type `{integer}`
|
||||
found tuple `(isize, isize)`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5100.rs:8:9
|
||||
|
|
||||
LL | enum A { B, C }
|
||||
| - unit variant defined here
|
||||
...
|
||||
LL | match (true, false) {
|
||||
| ------------- this expression has type `(bool, bool)`
|
||||
LL | A::B => (),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-7867.rs:7:9
|
||||
|
|
||||
LL | enum A { B, C }
|
||||
| - unit variant defined here
|
||||
...
|
||||
LL | match (true, false) {
|
||||
| ------------- this expression has type `(bool, bool)`
|
||||
LL | A::B => (),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue