Allow : after pat_param - #162264
Open
coolreader18 wants to merge 2 commits into
Open
Conversation
Collaborator
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
|
This definitely would need approval from the lang team. cc @rust-lang/lang @rust-lang/lang-advisors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As on the tin. Perhaps this requires a more formal decision process, but in my view this is something of a bug. Originally,
pat_paramwas just the bikeshodden name ofpat2015, c.f. #83386 (comment):But if it truly is a matcher for "a pattern you can use for a parameter", there shouldn't be a problem allowing it to be followed by a colon, given that that's kind of the definitional constraint for that grammar. And if, in the distant future, the language decides to separate the name and type of a parameter with something other than a colon, well, that'll need an edition change anyway.
In my opinion, this would resolve #87724: I'd imagine that most-if-not-all use cases for a
patfollowed by a colon are for matching function signatures or let statements, which don't let you use|patterns anyway. But, we get to have our cake and eat it too by still reserving:for future extensions tomatchexpression (pat) patterns. If it ever is desired to makepatmatch the whole$pat : $tysyntax, as mentioned in #87724 (comment), that's something that can be done over an edition boundary and/or just forpatmatchers.