Repository navigation
feat: complete turbofish when fn can't infer param - #23473
Conversation
Example
---
```rust
fn main() {
size_of$0
}
```
**Before this PR**
```rust
fn main() {
size_of()
}
```
**After this PR**
```rust
fn main() {
size_of::<$1>()
}
```
|
|
||
| if let Some((cap, (self_param, params))) = complete_call_parens { | ||
| let with_type_param = || { | ||
| let gen_params = hir::GenericDef::Function(func).type_or_const_params(db); |
There was a problem hiding this comment.
This accounts for impl Traits which cannot be turbofished.
There was a problem hiding this comment.
That's no problem, because params.is_empty()
There was a problem hiding this comment.
Uhm, right, but then why only when there are no params?
There was a problem hiding this comment.
- It's very simple, otherwise it's complex
- If the params is not empty, it is difficult to predict whether the user wants to complete generics or params first
There was a problem hiding this comment.
Right, it'll have to check if the parameters contain the generic params. Which is possible but harder.
(2) isn't really a problem IMO, any order will be good.
Currently, the implementation covers unambiguous cases, perhaps without the need for config? |
People don't like it when we mess with what they're used to. I believe every major change to IDE feature requires config. |
| /// Term search fuel in "units of work" for autocompletion (Defaults to 1000). | ||
| completion_termSearch_fuel: usize = 1000, | ||
|
|
||
| /// Complete turbofish (`::<>`) at the call site (if needs). |
There was a problem hiding this comment.
| /// Complete turbofish (`::<>`) at the call site (if needs). | |
| /// Complete turbofish (`::<>`) at the call site (if needed). |
Calculate simple cases to avoid performance waste as much as possible
Example
Before this PR
After this PR