Skip to content

Commit e374772

Browse files
committed
parser: extract recover_inner_leading_vert.
1 parent 3a40542 commit e374772

File tree

1 file changed

+7
-4
lines changed
  • src/libsyntax/parse/parser

1 file changed

+7
-4
lines changed

src/libsyntax/parse/parser/pat.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,13 @@ impl<'a> Parser<'a> {
178178
/// Recursive possibly-or-pattern parser with recovery for an erroneous leading `|`.
179179
/// See `parse_pat_with_or` for details on parsing or-patterns.
180180
fn parse_pat_with_or_inner(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
181-
// Recover if `|` or `||` is here.
182-
// The user is thinking that a leading `|` is allowed in this position.
181+
self.recover_inner_leading_vert();
182+
self.parse_pat_with_or(expected, GateOr::Yes, TopLevel::No)
183+
}
184+
185+
/// Recover if `|` or `||` is here.
186+
/// The user is thinking that a leading `|` is allowed in this position.
187+
fn recover_inner_leading_vert(&mut self) {
183188
if let token::BinOp(token::Or) | token::OrOr = self.token.kind {
184189
let span = self.token.span;
185190
let rm_msg = format!("remove the `{}`", pprust::token_to_string(&self.token));
@@ -190,8 +195,6 @@ impl<'a> Parser<'a> {
190195

191196
self.bump();
192197
}
193-
194-
self.parse_pat_with_or(expected, GateOr::Yes, TopLevel::No)
195198
}
196199

197200
/// Parses a pattern, with a setting whether modern range patterns (e.g., `a..=b`, `a..b` are

0 commit comments

Comments
 (0)