about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-24 23:10:46 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-08-24 23:10:46 +0200
commite3747722fbb8a44f9053922e4c39338a3a1f9597 (patch)
treea8bcf2d7989a7b8cbf4ed6cb73e95739c41d9ff6 /src/libsyntax/parse/parser
parent3a405421e7c1437416e225ea8d2f0fdfb501df7b (diff)
downloadrust-e3747722fbb8a44f9053922e4c39338a3a1f9597.tar.gz
rust-e3747722fbb8a44f9053922e4c39338a3a1f9597.zip
parser: extract recover_inner_leading_vert.
Diffstat (limited to 'src/libsyntax/parse/parser')
-rw-r--r--src/libsyntax/parse/parser/pat.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs
index 724edbcfaed..dc6632cf10d 100644
--- a/src/libsyntax/parse/parser/pat.rs
+++ b/src/libsyntax/parse/parser/pat.rs
@@ -178,8 +178,13 @@ impl<'a> Parser<'a> {
     /// Recursive possibly-or-pattern parser with recovery for an erroneous leading `|`.
     /// See `parse_pat_with_or` for details on parsing or-patterns.
     fn parse_pat_with_or_inner(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
-        // Recover if `|` or `||` is here.
-        // The user is thinking that a leading `|` is allowed in this position.
+        self.recover_inner_leading_vert();
+        self.parse_pat_with_or(expected, GateOr::Yes, TopLevel::No)
+    }
+
+    /// Recover if `|` or `||` is here.
+    /// The user is thinking that a leading `|` is allowed in this position.
+    fn recover_inner_leading_vert(&mut self) {
         if let token::BinOp(token::Or) | token::OrOr = self.token.kind {
             let span = self.token.span;
             let rm_msg = format!("remove the `{}`", pprust::token_to_string(&self.token));
@@ -190,8 +195,6 @@ impl<'a> Parser<'a> {
 
             self.bump();
         }
-
-        self.parse_pat_with_or(expected, GateOr::Yes, TopLevel::No)
     }
 
     /// Parses a pattern, with a setting whether modern range patterns (e.g., `a..=b`, `a..b` are