@@ -97,9 +97,9 @@ pub enum PatternLocation {
97
97
impl < ' a > Parser < ' a > {
98
98
/// Parses a pattern.
99
99
///
100
- /// Corresponds to `pat<no_top_alt> ` in RFC 2535 and does not admit or-patterns
101
- /// at the top level. Used when parsing the parameters of lambda expressions,
102
- /// functions, function pointers, and `pat ` macro fragments.
100
+ /// Corresponds to `PatternNoTopAlt ` in RFC 3637 and does not admit or-patterns
101
+ /// or guard patterns at the top level. Used when parsing the parameters of lambda
102
+ /// expressions, functions, function pointers, and `pat_param ` macro fragments.
103
103
pub fn parse_pat_no_top_alt (
104
104
& mut self ,
105
105
expected : Option < Expected > ,
@@ -110,25 +110,26 @@ impl<'a> Parser<'a> {
110
110
111
111
/// Parses a pattern.
112
112
///
113
- /// Corresponds to `top_pat` in RFC 2535 and allows or-pattern at the top level.
114
- /// Used for parsing patterns in all cases when `pat<no_top_alt>` is not used.
113
+ /// Corresponds to `PatternNoTopGuard` in RFC 3637 and allows or-patterns, but not
114
+ /// guard patterns, at the top level. Used for parsing patterns in `pat` fragments and
115
+ /// `let`, `if let`, and `while let` expressions.
115
116
///
116
117
/// Note that after the FCP in <https://github.com/rust-lang/rust/issues/81415>,
117
118
/// a leading vert is allowed in nested or-patterns, too. This allows us to
118
119
/// simplify the grammar somewhat.
119
- pub fn parse_pat_allow_top_alt (
120
+ pub fn parse_pat_no_top_guard (
120
121
& mut self ,
121
122
expected : Option < Expected > ,
122
123
rc : RecoverComma ,
123
124
ra : RecoverColon ,
124
125
rt : CommaRecoveryMode ,
125
126
) -> PResult < ' a , P < Pat > > {
126
- self . parse_pat_allow_top_alt_inner ( expected, rc, ra, rt, None ) . map ( |( pat, _) | pat)
127
+ self . parse_pat_no_top_guard_inner ( expected, rc, ra, rt, None ) . map ( |( pat, _) | pat)
127
128
}
128
129
129
130
/// Returns the pattern and a bool indicating whether we recovered from a trailing vert (true =
130
131
/// recovered).
131
- fn parse_pat_allow_top_alt_inner (
132
+ fn parse_pat_no_top_guard_inner (
132
133
& mut self ,
133
134
expected : Option < Expected > ,
134
135
rc : RecoverComma ,
@@ -229,7 +230,7 @@ impl<'a> Parser<'a> {
229
230
// We use `parse_pat_allow_top_alt` regardless of whether we actually want top-level
230
231
// or-patterns so that we can detect when a user tries to use it. This allows us to print a
231
232
// better error message.
232
- let ( pat, trailing_vert) = self . parse_pat_allow_top_alt_inner (
233
+ let ( pat, trailing_vert) = self . parse_pat_no_top_guard_inner (
233
234
expected,
234
235
rc,
235
236
RecoverColon :: No ,
@@ -696,7 +697,7 @@ impl<'a> Parser<'a> {
696
697
} else if self . check ( & token:: OpenDelim ( Delimiter :: Bracket ) ) {
697
698
// Parse `[pat, pat,...]` as a slice pattern.
698
699
let ( pats, _) = self . parse_delim_comma_seq ( Delimiter :: Bracket , |p| {
699
- p. parse_pat_allow_top_alt (
700
+ p. parse_pat_no_top_guard (
700
701
None ,
701
702
RecoverComma :: No ,
702
703
RecoverColon :: No ,
@@ -944,7 +945,7 @@ impl<'a> Parser<'a> {
944
945
let open_paren = self . token . span ;
945
946
946
947
let ( fields, trailing_comma) = self . parse_paren_comma_seq ( |p| {
947
- p. parse_pat_allow_top_alt (
948
+ p. parse_pat_no_top_guard (
948
949
None ,
949
950
RecoverComma :: No ,
950
951
RecoverColon :: No ,
@@ -1359,7 +1360,7 @@ impl<'a> Parser<'a> {
1359
1360
path : Path ,
1360
1361
) -> PResult < ' a , PatKind > {
1361
1362
let ( fields, _) = self . parse_paren_comma_seq ( |p| {
1362
- p. parse_pat_allow_top_alt (
1363
+ p. parse_pat_no_top_guard (
1363
1364
None ,
1364
1365
RecoverComma :: No ,
1365
1366
RecoverColon :: No ,
@@ -1394,7 +1395,7 @@ impl<'a> Parser<'a> {
1394
1395
self . parse_builtin ( |self_, _lo, ident| {
1395
1396
Ok ( match ident. name {
1396
1397
// builtin#deref(PAT)
1397
- sym:: deref => Some ( ast:: PatKind :: Deref ( self_. parse_pat_allow_top_alt (
1398
+ sym:: deref => Some ( ast:: PatKind :: Deref ( self_. parse_pat_no_top_guard (
1398
1399
None ,
1399
1400
RecoverComma :: Yes ,
1400
1401
RecoverColon :: Yes ,
@@ -1669,7 +1670,7 @@ impl<'a> Parser<'a> {
1669
1670
// Parsing a pattern of the form `fieldname: pat`.
1670
1671
let fieldname = self . parse_field_name ( ) ?;
1671
1672
self . bump ( ) ;
1672
- let pat = self . parse_pat_allow_top_alt (
1673
+ let pat = self . parse_pat_no_top_guard (
1673
1674
None ,
1674
1675
RecoverComma :: No ,
1675
1676
RecoverColon :: No ,
0 commit comments