Completions in macros should be aware of completing multiple idents #11058
Open
Description
When typing inside a macro we should consider all downmapped positions of the ident we are currently typing out instead of just the first one, that way we get more completions that might make sense.
Example given the following macro:
macro_rules! tuple_to_record_closure {
($ident:ident { $( $field:ident ),+ $(,)? }) => {
|($( $field ),+)| $ident { $( $field ),+ }
};
}
struct Foo { foo: () }
fn main() {
tuple_to_record_closure! {
Foo {
f$0
}
}
}
Typing at the given position should offer the completion of the foo
field as the ident is downmapped to a field position as its second usage, currently we only consider the parameter position though.
This also has the potential to create a lot of duplicate completions which have to be filtered out, as well as making completions in macros potentially very slow if we were to stupidly repeat completions for each downmapped token, so this probably requires some architecture changes if we want to pursue this.
cc #11059