Completions in macros should consider the fragment type they are part of #11059
Open
Description
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 cursor position gives us various completions, one of which is the Foo { foo }: Foo
pattern completion as the identifier is used in a pattern position in the expansion. This completion is wrong though, as applying it will lead to syntax errors. In this case we need to consider that the identifier we are completing is being captures as an $ident
fragment, as such only stupid identifier completions should be allowed. OTOH if it was a $pat
fragment capture, this completion would be fine.
We currently lack the ability of figuring out what kind of fragment type a token got captured by, so that needs to be done first. #11183
cc #11058