diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-18 15:31:34 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-24 21:31:54 +0200 |
| commit | 1ba7550a8996cffc07c6af89dcd6e1cdc63b24cf (patch) | |
| tree | acc7f42fe5401fe2ae33012f373bd201bc51adb6 /src/libsyntax/parse/parser | |
| parent | 5299d8a191246cf55c8ead7b8be68c8aeca78d35 (diff) | |
| download | rust-1ba7550a8996cffc07c6af89dcd6e1cdc63b24cf.tar.gz rust-1ba7550a8996cffc07c6af89dcd6e1cdc63b24cf.zip | |
parser: type alias `type Expected = Option<&'static str>;`.
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/pat.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 4cda14907e4..36d5ed5c4aa 100644 --- a/src/libsyntax/parse/parser/pat.rs +++ b/src/libsyntax/parse/parser/pat.rs @@ -12,12 +12,11 @@ use crate::ThinVec; 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 @@ impl<'a> Parser<'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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'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 @@ impl<'a> Parser<'a> { 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); |
