mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
fix: Fix pat fragment parsers choking on <eoi>
This commit is contained in:
parent
8846b5cf4a
commit
f9bb5476c3
2 changed files with 39 additions and 1 deletions
|
@ -1883,3 +1883,41 @@ fn test() {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pat_fragment_eof_17441() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! matches {
|
||||||
|
($expression:expr, $pattern:pat $(if $guard:expr)? ) => {
|
||||||
|
match $expression {
|
||||||
|
$pattern $(if $guard)? => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
fn f() {
|
||||||
|
matches!(0, 10..);
|
||||||
|
matches!(0, 10.. if true);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! matches {
|
||||||
|
($expression:expr, $pattern:pat $(if $guard:expr)? ) => {
|
||||||
|
match $expression {
|
||||||
|
$pattern $(if $guard)? => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
fn f() {
|
||||||
|
match 0 {
|
||||||
|
10.. =>true , _=>false
|
||||||
|
};
|
||||||
|
match 0 {
|
||||||
|
10..if true =>true , _=>false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
||||||
// ^
|
// ^
|
||||||
if matches!(
|
if matches!(
|
||||||
p.current(),
|
p.current(),
|
||||||
T![=] | T![,] | T![:] | T![')'] | T!['}'] | T![']'] | T![if]
|
T![=] | T![,] | T![:] | T![')'] | T!['}'] | T![']'] | T![if] | EOF
|
||||||
) {
|
) {
|
||||||
// test half_open_range_pat
|
// test half_open_range_pat
|
||||||
// fn f() {
|
// fn f() {
|
||||||
|
|
Loading…
Reference in a new issue