mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
Auto merge of #13777 - dzvon:fix-13776, r=jonas-schievink
fix: add a check for `if` token in patterns parser Closes #13776
This commit is contained in:
commit
4909d4fbdb
@ -126,11 +126,21 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
||||
// ^
|
||||
// `[0..]`
|
||||
// ^
|
||||
if matches!(p.current(), T![=] | T![,] | T![:] | T![')'] | T!['}'] | T![']']) {
|
||||
// `0 .. if`
|
||||
// ^
|
||||
if matches!(
|
||||
p.current(),
|
||||
T![=] | T![,] | T![:] | T![')'] | T!['}'] | T![']'] | T![if]
|
||||
) {
|
||||
// test half_open_range_pat
|
||||
// fn f() {
|
||||
// let 0 .. = 1u32;
|
||||
// let 0..: _ = 1u32;
|
||||
//
|
||||
// match 42 {
|
||||
// 0 .. if true => (),
|
||||
// _ => (),
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
atom_pat(p, recovery_set);
|
||||
|
@ -46,6 +46,49 @@ SOURCE_FILE
|
||||
LITERAL
|
||||
INT_NUMBER "1u32"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n\n "
|
||||
MATCH_EXPR
|
||||
MATCH_KW "match"
|
||||
WHITESPACE " "
|
||||
LITERAL
|
||||
INT_NUMBER "42"
|
||||
WHITESPACE " "
|
||||
MATCH_ARM_LIST
|
||||
L_CURLY "{"
|
||||
WHITESPACE "\n "
|
||||
MATCH_ARM
|
||||
RANGE_PAT
|
||||
LITERAL_PAT
|
||||
LITERAL
|
||||
INT_NUMBER "0"
|
||||
WHITESPACE " "
|
||||
DOT2 ".."
|
||||
WHITESPACE " "
|
||||
MATCH_GUARD
|
||||
IF_KW "if"
|
||||
WHITESPACE " "
|
||||
LITERAL
|
||||
TRUE_KW "true"
|
||||
WHITESPACE " "
|
||||
FAT_ARROW "=>"
|
||||
WHITESPACE " "
|
||||
TUPLE_EXPR
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
COMMA ","
|
||||
WHITESPACE "\n "
|
||||
MATCH_ARM
|
||||
WILDCARD_PAT
|
||||
UNDERSCORE "_"
|
||||
WHITESPACE " "
|
||||
FAT_ARROW "=>"
|
||||
WHITESPACE " "
|
||||
TUPLE_EXPR
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
COMMA ","
|
||||
WHITESPACE "\n "
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
|
@ -1,4 +1,9 @@
|
||||
fn f() {
|
||||
let 0 .. = 1u32;
|
||||
let 0..: _ = 1u32;
|
||||
|
||||
match 42 {
|
||||
0 .. if true => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user