Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/patterns.md
Copy link
Copy Markdown
Member Author

@fmease fmease May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with reverting the RangeModernRange 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.

View changes since the review

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ r[patterns.syntax]
Pattern -> `|`? PatternNoTopAlt ( `|` PatternNoTopAlt )*

PatternNoTopAlt ->
PatternWithoutRange
| RangePattern
PatternWithoutModernRange
| ModernRangePattern

PatternWithoutRange ->
PatternWithoutModernRange ->
LiteralPattern
| IdentifierPattern
| WildcardPattern
Expand All @@ -22,8 +22,11 @@ PatternWithoutRange ->
| SlicePattern
| PathPattern
| MacroInvocation
| ObsoleteRangePattern[^obsolete-range-edition]
```

[^obsolete-range-edition]: The [ObsoleteRangePattern] syntax is semantically invalid in the 2021 edition and beyond.

r[patterns.intro]
Patterns are used to match values against structures and to, optionally, bind variables to values inside these structures. They are also used in variable declarations and parameters for functions and closures.

Expand Down Expand Up @@ -464,13 +467,12 @@ r[patterns.range]

r[patterns.range.syntax]
```grammar,patterns
RangePattern ->
ModernRangePattern ->
RangeExclusivePattern
| RangeInclusivePattern
| RangeFromPattern
| RangeToExclusivePattern
| RangeToInclusivePattern
| ObsoleteRangePattern[^obsolete-range-edition]

RangeExclusivePattern ->
RangePatternBound `..` RangePatternBound
Expand All @@ -495,8 +497,6 @@ RangePatternBound ->
| PathExpression
```

[^obsolete-range-edition]: The [ObsoleteRangePattern] syntax has been removed in the 2021 edition.

r[patterns.range.intro]
*Range patterns* match scalar values within the range defined by their bounds. They comprise a *sigil* (`..` or `..=`) and a bound on one or both sides.

Expand Down Expand Up @@ -659,7 +659,7 @@ r[patterns.ref]

r[patterns.ref.syntax]
```grammar,patterns
ReferencePattern -> (`&`|`&&`) `mut`? PatternWithoutRange
ReferencePattern -> (`&`|`&&`) `mut`? PatternWithoutModernRange
```

r[patterns.ref.intro]
Expand Down
Loading