@@ -97,9 +97,9 @@ pub enum PatternLocation {
9797impl < ' a > Parser < ' a > {
9898 /// Parses a pattern.
9999 ///
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.
103103 pub fn parse_pat_no_top_alt (
104104 & mut self ,
105105 expected : Option < Expected > ,
@@ -110,25 +110,26 @@ impl<'a> Parser<'a> {
110110
111111 /// Parses a pattern.
112112 ///
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.
115116 ///
116117 /// Note that after the FCP in <https://github.com/rust-lang/rust/issues/81415>,
117118 /// a leading vert is allowed in nested or-patterns, too. This allows us to
118119 /// simplify the grammar somewhat.
119- pub fn parse_pat_allow_top_alt (
120+ pub fn parse_pat_no_top_guard (
120121 & mut self ,
121122 expected : Option < Expected > ,
122123 rc : RecoverComma ,
123124 ra : RecoverColon ,
124125 rt : CommaRecoveryMode ,
125126 ) -> 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)
127128 }
128129
129130 /// Returns the pattern and a bool indicating whether we recovered from a trailing vert (true =
130131 /// recovered).
131- fn parse_pat_allow_top_alt_inner (
132+ fn parse_pat_no_top_guard_inner (
132133 & mut self ,
133134 expected : Option < Expected > ,
134135 rc : RecoverComma ,
@@ -229,7 +230,7 @@ impl<'a> Parser<'a> {
229230 // We use `parse_pat_allow_top_alt` regardless of whether we actually want top-level
230231 // or-patterns so that we can detect when a user tries to use it. This allows us to print a
231232 // 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 (
233234 expected,
234235 rc,
235236 RecoverColon :: No ,
@@ -696,7 +697,7 @@ impl<'a> Parser<'a> {
696697 } else if self . check ( & token:: OpenDelim ( Delimiter :: Bracket ) ) {
697698 // Parse `[pat, pat,...]` as a slice pattern.
698699 let ( pats, _) = self . parse_delim_comma_seq ( Delimiter :: Bracket , |p| {
699- p. parse_pat_allow_top_alt (
700+ p. parse_pat_no_top_guard (
700701 None ,
701702 RecoverComma :: No ,
702703 RecoverColon :: No ,
@@ -944,7 +945,7 @@ impl<'a> Parser<'a> {
944945 let open_paren = self . token . span ;
945946
946947 let ( fields, trailing_comma) = self . parse_paren_comma_seq ( |p| {
947- p. parse_pat_allow_top_alt (
948+ p. parse_pat_no_top_guard (
948949 None ,
949950 RecoverComma :: No ,
950951 RecoverColon :: No ,
@@ -1359,7 +1360,7 @@ impl<'a> Parser<'a> {
13591360 path : Path ,
13601361 ) -> PResult < ' a , PatKind > {
13611362 let ( fields, _) = self . parse_paren_comma_seq ( |p| {
1362- p. parse_pat_allow_top_alt (
1363+ p. parse_pat_no_top_guard (
13631364 None ,
13641365 RecoverComma :: No ,
13651366 RecoverColon :: No ,
@@ -1394,7 +1395,7 @@ impl<'a> Parser<'a> {
13941395 self . parse_builtin ( |self_, _lo, ident| {
13951396 Ok ( match ident. name {
13961397 // 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 (
13981399 None ,
13991400 RecoverComma :: Yes ,
14001401 RecoverColon :: Yes ,
@@ -1669,7 +1670,7 @@ impl<'a> Parser<'a> {
16691670 // Parsing a pattern of the form `fieldname: pat`.
16701671 let fieldname = self . parse_field_name ( ) ?;
16711672 self . bump ( ) ;
1672- let pat = self . parse_pat_allow_top_alt (
1673+ let pat = self . parse_pat_no_top_guard (
16731674 None ,
16741675 RecoverComma :: No ,
16751676 RecoverColon :: No ,
0 commit comments