Fix grammar rules pertaining to obsolete range patterns#2259
Open
fmease wants to merge 1 commit intorust-lang:masterfrom
Open
Fix grammar rules pertaining to obsolete range patterns#2259fmease wants to merge 1 commit intorust-lang:masterfrom
fmease wants to merge 1 commit intorust-lang:masterfrom
Conversation
fmease
commented
May 5, 2026
Member
Author
There was a problem hiding this comment.
I'm fine with reverting the Range → ModernRange renaming.
Advantage of the renaming: It prevents confusion that could lead to people repeatedly opening issues and PRs trying to move ObsoleteRangePattern back into RangePattern believing it to be a mistake.
Disadvantage of the renaming: It painfully highlights the fact that there are modern and obsolete range patterns; the latter are no longer hidden at the bottom of RangePattern's definition.
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.
reference@master incorrectly claims that the following patterns are syntactically invalid:
&0...0,&mut 0...0. As a matter of fact, rustc specifically continues to accept obsolete range patterns as the "pointee" of reference patterns; it only rejects modern range patterns in this position (e.g.,&..1,&0..,&mut 0..1,&&0..=0,&&mut ..=0).Of course, the fact that pattern
&0...1and expression&0..=1get interpreted differently wrt. precedence (&(0...1)and(&0)..=1, respectively) has been identified as a bug: rust-lang/rust#48501 (2018).It's unclear to me if people have run crater back then to see if rejecting patterns like
&0...0would lead to any regressions. In any case, in PR rust-lang/rust#47813 (2018) it was only made an error for modern range patterns.I don't think I have the time and energy to issue a crater run for this since I've been issuing crater run after crater run as of late. So I don't plan on fixing rust-lang/rust#48501 anytime soon. However, I figured it would make sense to update the Reference. As far as I understand it, the Reference is descriptive rather than prescriptive, so even though this is a bug in rustc, it's worth documenting it IMHO, esp. since it's so old.
Finally, the footnote for ObsoleteRangePattern made it sound like this grammar rule stopped being in effect in Rust 2021 and beyond whilst in reality
...patterns have only become semantically invalid in Rust 2021 and following, not syntactically. So I've clarified it.