Fix tuple struct pat expected type#21333
Conversation
Example
---
```rust
struct Foo(Option<i32>);
fn foo(x: Foo) -> Foo {
match x { Foo($0) => () }
}
```
**Before this PR**
```rust
ty: Foo, name: ?
```
**After this PR**
```rust
ty: Option<i32>, name: ?
```
|
I'm really not pleased with the ways the expected type inference in completion is going. We're essentially duplicating the entire logic of type inference. I don't think that's sustainable. We need to find a better way, and I hesitate to merge more PRs in this area until we have a plan. A possible half-solution is to wait for speculative execution, then query the type of the inserted identifier. @rust-lang/rust-analyzer thoughts? |
|
Sounds like a good idea, but I think we can merge this one since A4-Tacks already did the work and it's not very complex. |
Is inference on the modified syntax tree beneficial for caching? |
|
No, it is beneficial for completion (only possible when Salsa will gain speculative execution). |
|
Can this PR be merged now? |
|
This bug quite affects the user experience. I often type Similar tuple also has this bug, but the frequency of encountering it is far lower than this |
Example
Before this PR
After this PR