@@ -12,12 +12,11 @@ use crate::ThinVec;
12
12
13
13
use errors:: { Applicability , DiagnosticBuilder } ;
14
14
15
+ type Expected = Option < & ' static str > ;
16
+
15
17
impl < ' a > Parser < ' a > {
16
18
/// 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 > > {
21
20
self . parse_pat_with_range_pat ( true , expected)
22
21
}
23
22
@@ -105,7 +104,7 @@ impl<'a> Parser<'a> {
105
104
}
106
105
107
106
/// 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 > > {
109
108
// Parse the first pattern.
110
109
let first_pat = self . parse_pat ( expected) ?;
111
110
@@ -135,7 +134,7 @@ impl<'a> Parser<'a> {
135
134
fn parse_pat_with_range_pat (
136
135
& mut self ,
137
136
allow_range_pat : bool ,
138
- expected : Option < & ' static str > ,
137
+ expected : Expected ,
139
138
) -> PResult < ' a , P < Pat > > {
140
139
maybe_recover_from_interpolated_ty_qpath ! ( self , true ) ;
141
140
maybe_whole ! ( self , NtPat , |x| x) ;
@@ -257,7 +256,7 @@ impl<'a> Parser<'a> {
257
256
}
258
257
259
258
/// 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 > {
261
260
self . expect_and ( ) ?;
262
261
let mutbl = self . parse_mutability ( ) ;
263
262
@@ -363,7 +362,7 @@ impl<'a> Parser<'a> {
363
362
fn fatal_unexpected_non_pat (
364
363
& mut self ,
365
364
mut err : DiagnosticBuilder < ' a > ,
366
- expected : Option < & ' static str > ,
365
+ expected : Expected ,
367
366
) -> PResult < ' a , P < Pat > > {
368
367
self . cancel ( & mut err) ;
369
368
0 commit comments