@@ -49,7 +49,7 @@ impl<'a> Parser<'a> {
49
49
let gated_leading_vert = self . eat_or_separator ( ) && gate_or == GateOr :: Yes ;
50
50
51
51
// Parse the possibly-or-pattern.
52
- let pat = self . parse_pat_with_or ( None , gate_or, TopLevel :: Yes ) ?;
52
+ let pat = self . parse_pat_with_or ( gate_or, TopLevel :: Yes ) ?;
53
53
54
54
// If we parsed a leading `|` which should be gated,
55
55
// and no other gated or-pattern has been parsed thus far,
@@ -67,14 +67,9 @@ impl<'a> Parser<'a> {
67
67
68
68
/// Parses a pattern, that may be a or-pattern (e.g. `Foo | Bar` in `Some(Foo | Bar)`).
69
69
/// Corresponds to `pat<allow_top_alt>` in RFC 2535.
70
- fn parse_pat_with_or (
71
- & mut self ,
72
- expected : Expected ,
73
- gate_or : GateOr ,
74
- top_level : TopLevel ,
75
- ) -> PResult < ' a , P < Pat > > {
70
+ fn parse_pat_with_or ( & mut self , gate_or : GateOr , top_level : TopLevel ) -> PResult < ' a , P < Pat > > {
76
71
// Parse the first pattern.
77
- let first_pat = self . parse_pat ( expected ) ?;
72
+ let first_pat = self . parse_pat ( None ) ?;
78
73
self . maybe_recover_unexpected_comma ( first_pat. span , top_level) ?;
79
74
80
75
// If the next token is not a `|`,
@@ -86,7 +81,7 @@ impl<'a> Parser<'a> {
86
81
let lo = first_pat. span ;
87
82
let mut pats = vec ! [ first_pat] ;
88
83
while self . eat_or_separator ( ) {
89
- let pat = self . parse_pat ( expected ) ?;
84
+ let pat = self . parse_pat ( None ) ?;
90
85
self . maybe_recover_unexpected_comma ( pat. span , top_level) ?;
91
86
pats. push ( pat) ;
92
87
}
@@ -177,9 +172,9 @@ impl<'a> Parser<'a> {
177
172
178
173
/// Recursive possibly-or-pattern parser with recovery for an erroneous leading `|`.
179
174
/// See `parse_pat_with_or` for details on parsing or-patterns.
180
- fn parse_pat_with_or_inner ( & mut self , expected : Expected ) -> PResult < ' a , P < Pat > > {
175
+ fn parse_pat_with_or_inner ( & mut self ) -> PResult < ' a , P < Pat > > {
181
176
self . recover_inner_leading_vert ( ) ;
182
- self . parse_pat_with_or ( expected , GateOr :: Yes , TopLevel :: No )
177
+ self . parse_pat_with_or ( GateOr :: Yes , TopLevel :: No )
183
178
}
184
179
185
180
/// Recover if `|` or `||` is here.
@@ -215,7 +210,7 @@ impl<'a> Parser<'a> {
215
210
// Parse `[pat, pat,...]` as a slice pattern.
216
211
let ( pats, _) = self . parse_delim_comma_seq (
217
212
token:: Bracket ,
218
- |p| p. parse_pat_with_or_inner ( None ) ,
213
+ |p| p. parse_pat_with_or_inner ( ) ,
219
214
) ?;
220
215
PatKind :: Slice ( pats)
221
216
}
@@ -344,9 +339,7 @@ impl<'a> Parser<'a> {
344
339
345
340
/// Parse a tuple or parenthesis pattern.
346
341
fn parse_pat_tuple_or_parens ( & mut self ) -> PResult < ' a , PatKind > {
347
- let ( fields, trailing_comma) = self . parse_paren_comma_seq ( |p| {
348
- p. parse_pat_with_or_inner ( None )
349
- } ) ?;
342
+ let ( fields, trailing_comma) = self . parse_paren_comma_seq ( |p| p. parse_pat_with_or_inner ( ) ) ?;
350
343
351
344
// Here, `(pat,)` is a tuple pattern.
352
345
// For backward compatibility, `(..)` is a tuple pattern as well.
@@ -589,7 +582,7 @@ impl<'a> Parser<'a> {
589
582
err. span_label ( self . token . span , msg) ;
590
583
return Err ( err) ;
591
584
}
592
- let ( fields, _) = self . parse_paren_comma_seq ( |p| p. parse_pat_with_or_inner ( None ) ) ?;
585
+ let ( fields, _) = self . parse_paren_comma_seq ( |p| p. parse_pat_with_or_inner ( ) ) ?;
593
586
Ok ( PatKind :: TupleStruct ( path, fields) )
594
587
}
595
588
@@ -733,7 +726,7 @@ impl<'a> Parser<'a> {
733
726
// Parsing a pattern of the form "fieldname: pat"
734
727
let fieldname = self . parse_field_name ( ) ?;
735
728
self . bump ( ) ;
736
- let pat = self . parse_pat_with_or_inner ( None ) ?;
729
+ let pat = self . parse_pat_with_or_inner ( ) ?;
737
730
hi = pat. span ;
738
731
( pat, fieldname, false )
739
732
} else {
0 commit comments