Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for legal binding name in the ident of Pat::Ident #1627

Merged
merged 1 commit into from Apr 18, 2024
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Apr 18, 2024

The Ident::parse_any in this code is here to support #517 in syn 0.15. At the time, the function argument in fn 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 of FnArg held a Pat only, a Type only, self, mut self, &self, or &mut self, none of which are suitable for the form self: T. So self 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 but self continues to be considered a legal Pat::Ident. Keywords other than self should not be, however. For example:

if let Some(ref mut extern) = x {}

@dtolnay dtolnay merged commit 1b20403 into master Apr 18, 2024
29 checks passed
@dtolnay dtolnay deleted the patident branch April 18, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant