File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
src/libsyntax/parse/parser Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -110,18 +110,25 @@ impl<'a> Parser<'a> {
110
110
111
111
// If the next token is not a `|`,
112
112
// this is not an or-pattern and we should exit here.
113
- if !self . check ( & token:: BinOp ( token:: Or ) ) {
113
+ if !self . check ( & token:: BinOp ( token:: Or ) ) && self . token != token :: OrOr {
114
114
return Ok ( first_pat)
115
115
}
116
116
117
117
let lo = first_pat. span ;
118
-
119
118
let mut pats = vec ! [ first_pat] ;
119
+ loop {
120
+ if self . token == token:: OrOr {
121
+ // Found `||`; Recover and pretend we parsed `|`.
122
+ self . ban_unexpected_or_or ( ) ;
123
+ self . bump ( ) ;
124
+ } else if self . eat ( & token:: BinOp ( token:: Or ) ) {
125
+ // Found `|`. Working towards a proper or-pattern.
126
+ } else {
127
+ break ;
128
+ }
120
129
121
- while self . eat ( & token:: BinOp ( token:: Or ) ) {
122
130
pats. push ( self . parse_pat_with_range_pat ( true , expected) ?) ;
123
131
}
124
-
125
132
let or_pattern_span = lo. to ( self . prev_span ) ;
126
133
127
134
// Feature gate the or-pattern if instructed:
You can’t perform that action at this time.
0 commit comments