Skip to content

Conversation

@A4-Tacks
Copy link
Member

Example

struct Foo(Option<i32>);
fn foo(x: Foo) -> Foo {
   match x { Foo($0) => () }
}

Before this PR

ty: Foo, name: ?

After this PR

ty: Option<i32>, name: ?

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: ?
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 25, 2025
@ChayimFriedman2
Copy link
Contributor

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?

@lnicola
Copy link
Member

lnicola commented Dec 25, 2025

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.

@A4-Tacks
Copy link
Member Author

then query the type of the inserted identifier.

Is inference on the modified syntax tree beneficial for caching?

@ChayimFriedman2
Copy link
Contributor

No, it is beneficial for completion (only possible when Salsa will gain speculative execution).

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants