@@ -31,14 +31,7 @@ impl<'a> Parser<'a> {
31
31
pats. push ( self . parse_top_level_pat ( ) ?) ;
32
32
33
33
if self . token == token:: OrOr {
34
- self . struct_span_err ( self . token . span , "unexpected token `||` after pattern" )
35
- . span_suggestion (
36
- self . token . span ,
37
- "use a single `|` to specify multiple patterns" ,
38
- "|" . to_owned ( ) ,
39
- Applicability :: MachineApplicable
40
- )
41
- . emit ( ) ;
34
+ self . ban_unexpected_or_or ( ) ;
42
35
self . bump ( ) ;
43
36
} else if self . eat ( & token:: BinOp ( token:: Or ) ) {
44
37
// This is a No-op. Continue the loop to parse the next
@@ -49,6 +42,17 @@ impl<'a> Parser<'a> {
49
42
} ;
50
43
}
51
44
45
+ fn ban_unexpected_or_or ( & mut self ) {
46
+ self . struct_span_err ( self . token . span , "unexpected token `||` after pattern" )
47
+ . span_suggestion (
48
+ self . token . span ,
49
+ "use a single `|` to specify multiple patterns" ,
50
+ "|" . to_owned ( ) ,
51
+ Applicability :: MachineApplicable
52
+ )
53
+ . emit ( ) ;
54
+ }
55
+
52
56
/// A wrapper around `parse_pat` with some special error handling for the
53
57
/// "top-level" patterns in a match arm, `for` loop, `let`, &c. (in contrast
54
58
/// to subpatterns within such).
@@ -116,9 +120,7 @@ impl<'a> Parser<'a> {
116
120
let mut pats = vec ! [ first_pat] ;
117
121
118
122
while self . eat ( & token:: BinOp ( token:: Or ) ) {
119
- pats. push ( self . parse_pat_with_range_pat (
120
- true , expected
121
- ) ?) ;
123
+ pats. push ( self . parse_pat_with_range_pat ( true , expected) ?) ;
122
124
}
123
125
124
126
let or_pattern_span = lo. to ( self . prev_span ) ;
0 commit comments