Given the following code:
enum Animal {
Walrus,
MantisShrimp
}
fn feed(animal: &mut Animal) {
match animal {
Wa /*cursor*/
}
}
we should suggest Animial::Walrus completion. The relevant completion handler is here. ctx.sema.type_of_pat(..) method can be used to get the type of the pattern.
We should do the same in expressions as well, actually! And to extend these type-based completions even further, we could e.g. suggest X::new() if the expected type is X (or any other static method on X returning X).
In this context, would also be cool if the name resolution issue for importing the variants actually got fixed (see #3988).
Most helpful comment
We should do the same in expressions as well, actually! And to extend these type-based completions even further, we could e.g. suggest
X::new()if the expected type isX(or any other static method onXreturningX).