Unnamed repository; edit this file 'description' to name the repository.
Merge #10449
10449: make Some(1..) parsed r=lnicola a=XFFXFF fixes https://github.com/rust-analyzer/rust-analyzer/issues/9066 [rustc_ty_utils/src/ty.rs](https://github.com/rust-lang/rust/blob/d7795d302adbb8c1547c952cd0d04a7f9ca29262/compiler/rustc_ty_utils/src/ty.rs#L524) Co-authored-by: zhoufan <[email protected]>
bors[bot] 2021-10-04
parent 4b7675f · parent a248f39 · commit 6ee3515
-rw-r--r--crates/parser/src/grammar/patterns.rs11
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast254
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs5
3 files changed, 178 insertions, 92 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 81e2051abb..60a7507c45 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -69,6 +69,11 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
// 200 .. 301 => (),
// 302 .. => (),
// }
+ //
+ // match Some(10 as u8) {
+ // Some(0) | None => (),
+ // Some(1..) => ()
+ // }
// }
// FIXME: support half_open_range_patterns (`..=2`),
@@ -78,9 +83,9 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
let m = lhs.precede(p);
p.bump(range_op);
- // `0 .. =>` or `let 0 .. =`
- // ^ ^
- if p.at(T![=]) {
+ // `0 .. =>` or `let 0 .. =` or `Some(0 .. )`
+ // ^ ^ ^
+ if p.at(T![=]) | p.at(T![')']) {
// test half_open_range_pat
// fn f() { let 0 .. = 1u32; }
} else {
diff --git a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
index 1a8979db89..5d5803f751 100644
--- a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
@@ -1,5 +1,5 @@
@@ -8,92 +8,168 @@ [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
index 3833fbd8d5..fa91efd212 100644
--- a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
+++ b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
@@ -5,4 +5,9 @@ fn main() {
200 .. 301 => (),
302 .. => (),
}
+
+ match Some(10 as u8) {
+ Some(0) | None => (),
+ Some(1..) => ()
+ }
}