Check for legal binding name in the ident of Pat::Ident #1627
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Ident::parse_any
in this code is here to support #517 in syn 0.15. At the time, the function argument infn f(self: T)
was parsed as https://docs.rs/syn/0.15.44/syn/enum.FnArg.html#variant.Captured in the form of a Pat, colon token, and Type. The only other variants ofFnArg
held a Pat only, a Type only,self
,mut self
,&self
, or&mut self
, none of which are suitable for the formself: T
. Soself
needed to be handled as some kind of Pat, and Pat::Ident was selected. (It might alternatively have been Pat::Path.)These days in syn 2, the function argument in
fn f(self: T)
is parsed as https://docs.rs/syn/2/syn/struct.Receiver.html butself
continues to be considered a legal Pat::Ident. Keywords other thanself
should not be, however. For example: