Skip to content

Commit 1ba7550

Browse files
committed
parser: type alias type Expected = Option<&'static str>;.
1 parent 5299d8a commit 1ba7550

File tree

1 file changed

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

1 file changed

+7
-8
lines changed

src/libsyntax/parse/parser/pat.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ use crate::ThinVec;
1212

1313
use errors::{Applicability, DiagnosticBuilder};
1414

15+
type Expected = Option<&'static str>;
16+
1517
impl<'a> Parser<'a> {
1618
/// Parses a pattern.
17-
pub fn parse_pat(
18-
&mut self,
19-
expected: Option<&'static str>
20-
) -> PResult<'a, P<Pat>> {
19+
pub fn parse_pat(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
2120
self.parse_pat_with_range_pat(true, expected)
2221
}
2322

@@ -105,7 +104,7 @@ impl<'a> Parser<'a> {
105104
}
106105

107106
/// Parses a pattern, that may be a or-pattern (e.g. `Some(Foo | Bar)`).
108-
fn parse_pat_with_or(&mut self, expected: Option<&'static str>) -> PResult<'a, P<Pat>> {
107+
fn parse_pat_with_or(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
109108
// Parse the first pattern.
110109
let first_pat = self.parse_pat(expected)?;
111110

@@ -135,7 +134,7 @@ impl<'a> Parser<'a> {
135134
fn parse_pat_with_range_pat(
136135
&mut self,
137136
allow_range_pat: bool,
138-
expected: Option<&'static str>,
137+
expected: Expected,
139138
) -> PResult<'a, P<Pat>> {
140139
maybe_recover_from_interpolated_ty_qpath!(self, true);
141140
maybe_whole!(self, NtPat, |x| x);
@@ -257,7 +256,7 @@ impl<'a> Parser<'a> {
257256
}
258257

259258
/// Parse `&pat` / `&mut pat`.
260-
fn parse_pat_deref(&mut self, expected: Option<&'static str>) -> PResult<'a, PatKind> {
259+
fn parse_pat_deref(&mut self, expected: Expected) -> PResult<'a, PatKind> {
261260
self.expect_and()?;
262261
let mutbl = self.parse_mutability();
263262

@@ -363,7 +362,7 @@ impl<'a> Parser<'a> {
363362
fn fatal_unexpected_non_pat(
364363
&mut self,
365364
mut err: DiagnosticBuilder<'a>,
366-
expected: Option<&'static str>,
365+
expected: Expected,
367366
) -> PResult<'a, P<Pat>> {
368367
self.cancel(&mut err);
369368

0 commit comments

Comments
 (0)