Parse range patterns in let statement with type annotation
This commit is contained in:
parent
a81c7a2974
commit
b14062aaec
@ -103,6 +103,8 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
||||
// ^
|
||||
// `let 0 .. =`
|
||||
// ^
|
||||
// `let 0..: _ =`
|
||||
// ^
|
||||
// (1.., _)
|
||||
// ^
|
||||
// `Some(0 .. )`
|
||||
@ -111,9 +113,12 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
||||
// ^
|
||||
// `[0..]`
|
||||
// ^
|
||||
if p.at(T![=]) | p.at(T![')']) | p.at(T![,]) | p.at(T!['}']) | p.at(T![']']) {
|
||||
if matches!(p.current(), T![=] | T![,] | T![:] | T![')'] | T!['}'] | T![']']) {
|
||||
// test half_open_range_pat
|
||||
// fn f() { let 0 .. = 1u32; }
|
||||
// fn f() {
|
||||
// let 0 .. = 1u32;
|
||||
// let 0..: _ = 1u32;
|
||||
// }
|
||||
} else {
|
||||
atom_pat(p, recovery_set);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ SOURCE_FILE
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
WHITESPACE " "
|
||||
WHITESPACE "\n "
|
||||
LET_STMT
|
||||
LET_KW "let"
|
||||
WHITESPACE " "
|
||||
@ -27,6 +27,25 @@ SOURCE_FILE
|
||||
LITERAL
|
||||
INT_NUMBER "1u32"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n "
|
||||
LET_STMT
|
||||
LET_KW "let"
|
||||
WHITESPACE " "
|
||||
RANGE_PAT
|
||||
LITERAL_PAT
|
||||
LITERAL
|
||||
INT_NUMBER "0"
|
||||
DOT2 ".."
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
INFER_TYPE
|
||||
UNDERSCORE "_"
|
||||
WHITESPACE " "
|
||||
EQ "="
|
||||
WHITESPACE " "
|
||||
LITERAL
|
||||
INT_NUMBER "1u32"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
|
@ -1 +1,4 @@
|
||||
fn f() { let 0 .. = 1u32; }
|
||||
fn f() {
|
||||
let 0 .. = 1u32;
|
||||
let 0..: _ = 1u32;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user