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-25 06:15:11 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-08-25 06:15:11 +0200
commitacb11305e8d7298750797d45324c0ecb3cc6c256 (patch)
treebbb0aac5180a54b90c512c3adfcaea26743288ae /src/libsyntax/parse/parser
parent6a73199da6c06c0b71ed6eeca578b00925137664 (diff)
downloadrust-acb11305e8d7298750797d45324c0ecb3cc6c256.tar.gz
rust-acb11305e8d7298750797d45324c0ecb3cc6c256.zip
parser: TopLevel -> RecoverComma.
Diffstat (limited to 'src/libsyntax/parse/parser')
-rw-r--r--src/libsyntax/parse/parser/pat.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs
index 1541031ec25..f2e269e03ba 100644
--- a/src/libsyntax/parse/parser/pat.rs
+++ b/src/libsyntax/parse/parser/pat.rs
@@ -21,9 +21,9 @@ pub(super) const PARAM_EXPECTED: Expected = Some("parameter name");
 #[derive(PartialEq)]
 pub enum GateOr { Yes, No }
 
-/// Whether or not this is the top level pattern context.
+/// Whether or not to recover a `,` when parsing or-patterns.
 #[derive(PartialEq, Copy, Clone)]
-enum TopLevel { Yes, No }
+enum RecoverComma { Yes, No }
 
 impl<'a> Parser<'a> {
     /// Parses a pattern.
@@ -52,7 +52,7 @@ impl<'a> Parser<'a> {
         let gated_leading_vert = self.eat_or_separator() && gate_or == GateOr::Yes;
 
         // Parse the possibly-or-pattern.
-        let pat = self.parse_pat_with_or(None, gate_or, TopLevel::Yes)?;
+        let pat = self.parse_pat_with_or(None, gate_or, RecoverComma::Yes)?;
 
         // If we parsed a leading `|` which should be gated,
         // and no other gated or-pattern has been parsed thus far,
@@ -72,7 +72,7 @@ impl<'a> Parser<'a> {
     /// Special recovery is provided for or-patterns and leading `|`.
     pub(super) fn parse_fn_param_pat(&mut self) -> PResult<'a, P<Pat>> {
         self.recover_leading_vert("not allowed in a parameter pattern");
-        let pat = self.parse_pat_with_or(PARAM_EXPECTED, GateOr::No, TopLevel::No)?;
+        let pat = self.parse_pat_with_or(PARAM_EXPECTED, GateOr::No, RecoverComma::No)?;
 
         if let PatKind::Or(..) = &pat.node {
             self.ban_illegal_fn_param_or_pat(&pat);
@@ -96,11 +96,11 @@ impl<'a> Parser<'a> {
         &mut self,
         expected: Expected,
         gate_or: GateOr,
-        top_level: TopLevel,
+        rc: RecoverComma,
     ) -> PResult<'a, P<Pat>> {
         // Parse the first pattern.
         let first_pat = self.parse_pat(expected)?;
-        self.maybe_recover_unexpected_comma(first_pat.span, top_level)?;
+        self.maybe_recover_unexpected_comma(first_pat.span, rc)?;
 
         // If the next token is not a `|`,
         // this is not an or-pattern and we should exit here.
@@ -115,7 +115,7 @@ impl<'a> Parser<'a> {
                 err.span_label(lo, "while parsing this or-pattern staring here");
                 err
             })?;
-            self.maybe_recover_unexpected_comma(pat.span, top_level)?;
+            self.maybe_recover_unexpected_comma(pat.span, rc)?;
             pats.push(pat);
         }
         let or_pattern_span = lo.to(self.prev_span);
@@ -156,8 +156,8 @@ impl<'a> Parser<'a> {
 
     /// Some special error handling for the "top-level" patterns in a match arm,
     /// `for` loop, `let`, &c. (in contrast to subpatterns within such).
-    fn maybe_recover_unexpected_comma(&mut self, lo: Span, top_level: TopLevel) -> PResult<'a, ()> {
-        if top_level == TopLevel::No || self.token != token::Comma {
+    fn maybe_recover_unexpected_comma(&mut self, lo: Span, rc: RecoverComma) -> PResult<'a, ()> {
+        if rc == RecoverComma::No || self.token != token::Comma {
             return Ok(());
         }
 
@@ -207,7 +207,7 @@ impl<'a> Parser<'a> {
     /// See `parse_pat_with_or` for details on parsing or-patterns.
     fn parse_pat_with_or_inner(&mut self) -> PResult<'a, P<Pat>> {
         self.recover_leading_vert("only allowed in a top-level pattern");
-        self.parse_pat_with_or(None, GateOr::Yes, TopLevel::No)
+        self.parse_pat_with_or(None, GateOr::Yes, RecoverComma::No)
     }
 
     /// Recover if `|` or `||` is here.