]> git.lizzy.rs Git - rust.git/commitdiff
parser: type alias `type Expected = Option<&'static str>;`.
authorMazdak Farrokhzad <twingoow@gmail.com>
Sun, 18 Aug 2019 13:31:34 +0000 (15:31 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sat, 24 Aug 2019 19:31:54 +0000 (21:31 +0200)
src/libsyntax/parse/parser/pat.rs

index 4cda14907e46c07c82b8f25a9dba7c29cb301052..36d5ed5c4aa640e5bc7a384f3273792639e94b10 100644 (file)
 
 use errors::{Applicability, DiagnosticBuilder};
 
+type Expected = Option<&'static str>;
+
 impl<'a> Parser<'a> {
     /// Parses a pattern.
-    pub fn parse_pat(
-        &mut self,
-        expected: Option<&'static str>
-    ) -> PResult<'a, P<Pat>> {
+    pub fn parse_pat(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
         self.parse_pat_with_range_pat(true, expected)
     }
 
@@ -105,7 +104,7 @@ fn skip_pat_list(&mut self) -> PResult<'a, ()> {
     }
 
     /// Parses a pattern, that may be a or-pattern (e.g. `Some(Foo | Bar)`).
-    fn parse_pat_with_or(&mut self, expected: Option<&'static str>) -> PResult<'a, P<Pat>> {
+    fn parse_pat_with_or(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
         // Parse the first pattern.
         let first_pat = self.parse_pat(expected)?;
 
@@ -135,7 +134,7 @@ fn parse_pat_with_or(&mut self, expected: Option<&'static str>) -> PResult<'a, P
     fn parse_pat_with_range_pat(
         &mut self,
         allow_range_pat: bool,
-        expected: Option<&'static str>,
+        expected: Expected,
     ) -> PResult<'a, P<Pat>> {
         maybe_recover_from_interpolated_ty_qpath!(self, true);
         maybe_whole!(self, NtPat, |x| x);
@@ -257,7 +256,7 @@ fn ban_pat_range_if_ambiguous(&self, pat: &Pat) -> PResult<'a, ()> {
     }
 
     /// Parse `&pat` / `&mut pat`.
-    fn parse_pat_deref(&mut self, expected: Option<&'static str>) -> PResult<'a, PatKind> {
+    fn parse_pat_deref(&mut self, expected: Expected) -> PResult<'a, PatKind> {
         self.expect_and()?;
         let mutbl = self.parse_mutability();
 
@@ -363,7 +362,7 @@ fn parse_pat_range_starting_with_lit(&mut self, begin: P<Expr>) -> PResult<'a, P
     fn fatal_unexpected_non_pat(
         &mut self,
         mut err: DiagnosticBuilder<'a>,
-        expected: Option<&'static str>,
+        expected: Expected,
     ) -> PResult<'a, P<Pat>> {
         self.cancel(&mut err);