mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Parse range patterns in struct and slice without trailing comma
This commit is contained in:
parent
1c03f45c08
commit
a81c7a2974
3 changed files with 150 additions and 3 deletions
|
@ -75,6 +75,16 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
|||
// Some(1..) => ()
|
||||
// }
|
||||
//
|
||||
// match () {
|
||||
// S { a: 0 } => (),
|
||||
// S { a: 1.. } => (),
|
||||
// }
|
||||
//
|
||||
// match () {
|
||||
// [0] => (),
|
||||
// [1..] => (),
|
||||
// }
|
||||
//
|
||||
// match (10 as u8, 5 as u8) {
|
||||
// (0, _) => (),
|
||||
// (1.., _) => ()
|
||||
|
@ -88,9 +98,20 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
|||
let m = lhs.precede(p);
|
||||
p.bump(range_op);
|
||||
|
||||
// `0 .. =>` or `let 0 .. =` or `Some(0 .. )`
|
||||
// ^ ^ ^
|
||||
if p.at(T![=]) | p.at(T![')']) | p.at(T![,]) {
|
||||
// testing if we're at one of the following positions:
|
||||
// `0 .. =>`
|
||||
// ^
|
||||
// `let 0 .. =`
|
||||
// ^
|
||||
// (1.., _)
|
||||
// ^
|
||||
// `Some(0 .. )`
|
||||
// ^
|
||||
// `S { t: 0.. }`
|
||||
// ^
|
||||
// `[0..]`
|
||||
// ^
|
||||
if p.at(T![=]) | p.at(T![')']) | p.at(T![,]) | p.at(T!['}']) | p.at(T![']']) {
|
||||
// test half_open_range_pat
|
||||
// fn f() { let 0 .. = 1u32; }
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue