-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-completionautocompletionautocompletionA-macromacro expansionmacro expansionC-ArchitectureBig architectural things which we need to figure up-front (or suggestions for rewrites :0) )Big architectural things which we need to figure up-front (or suggestions for rewrites :0) )E-unknownIt's unclear if the issue is E-hard or E-easy without digging inIt's unclear if the issue is E-hard or E-easy without digging inS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now
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
Metadata
Metadata
Assignees
Labels
A-completionautocompletionautocompletionA-macromacro expansionmacro expansionC-ArchitectureBig architectural things which we need to figure up-front (or suggestions for rewrites :0) )Big architectural things which we need to figure up-front (or suggestions for rewrites :0) )E-unknownIt's unclear if the issue is E-hard or E-easy without digging inIt's unclear if the issue is E-hard or E-easy without digging inS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now