Support exclusive_range_pattern

Fix #9779
This commit is contained in:
Jade
2021-08-03 21:31:57 -07:00
parent e3a67ccec6
commit b90ed92a5c
3 changed files with 42 additions and 21 deletions

View File

@@ -65,14 +65,18 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
// match 92 {
// 0 ... 100 => (),
// 101 ..= 200 => (),
// 200 .. 301=> (),
// 200 .. 301 => (),
// 302 .. => (),
// }
// }
for &range_op in [T![...], T![..=], T![..]].iter() {
if p.at(range_op) {
let m = lhs.precede(p);
p.bump(range_op);
atom_pat(p, recovery_set);
if !p.at(T![=>]) {
// not a range pat like `302 .. => ()`
atom_pat(p, recovery_set);
}
m.complete(p, RANGE_PAT);
return;
}
@@ -84,7 +88,7 @@ const PAT_RECOVERY_SET: TokenSet =
TokenSet::new(&[T![let], T![if], T![while], T![loop], T![match], T![')'], T![,], T![=]]);
fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
let m = match p.nth(0) {
let m = match p.current() {
T![box] => box_pat(p),
T![ref] | T![mut] => ident_pat(p, true),
T![const] => const_block_pat(p),