diff options
author | Matthew Jasper <[email protected]> | 2020-02-10 20:11:44 +0000 |
---|---|---|
committer | Matthew Jasper <[email protected]> | 2020-02-10 20:11:44 +0000 |
commit | 49b53cd7a0861cdba65643e3da441eefbe18d6e6 (patch) | |
tree | 67322ab09b687dab3801d9bec24ad9619fa8693b /crates | |
parent | 504e2a46bd71cd0fcaf7eb774216f65951761e38 (diff) |
Address review comments
Diffstat (limited to 'crates')
3 files changed, 66 insertions, 14 deletions
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index c6a2e4d39..3afbaa82b 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs | |||
@@ -41,16 +41,14 @@ fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { | |||
41 | let m = p.start(); | 41 | let m = p.start(); |
42 | pattern_single_r(p, recovery_set); | 42 | pattern_single_r(p, recovery_set); |
43 | 43 | ||
44 | let mut is_or_pat = false; | 44 | if !p.at(T![|]) { |
45 | m.abandon(p); | ||
46 | return; | ||
47 | } | ||
45 | while p.eat(T![|]) { | 48 | while p.eat(T![|]) { |
46 | is_or_pat = true; | ||
47 | pattern_single_r(p, recovery_set); | 49 | pattern_single_r(p, recovery_set); |
48 | } | 50 | } |
49 | if is_or_pat { | 51 | m.complete(p, OR_PAT); |
50 | m.complete(p, OR_PAT); | ||
51 | } else { | ||
52 | m.abandon(p); | ||
53 | } | ||
54 | } | 52 | } |
55 | 53 | ||
56 | fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) { | 54 | fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) { |
@@ -292,6 +290,9 @@ fn ref_pat(p: &mut Parser) -> CompletedMarker { | |||
292 | // test tuple_pat | 290 | // test tuple_pat |
293 | // fn main() { | 291 | // fn main() { |
294 | // let (a, b, ..) = (); | 292 | // let (a, b, ..) = (); |
293 | // let (a,) = (); | ||
294 | // let (..) = (); | ||
295 | // let () = (); | ||
295 | // } | 296 | // } |
296 | fn tuple_pat(p: &mut Parser) -> CompletedMarker { | 297 | fn tuple_pat(p: &mut Parser) -> CompletedMarker { |
297 | assert!(p.at(T!['('])); | 298 | assert!(p.at(T!['('])); |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs index f785acd36..ba719879d 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs | |||
@@ -1,3 +1,6 @@ | |||
1 | fn main() { | 1 | fn main() { |
2 | let (a, b, ..) = (); | 2 | let (a, b, ..) = (); |
3 | let (a,) = (); | ||
4 | let (..) = (); | ||
5 | let () = (); | ||
3 | } | 6 | } |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt index 674dec493..4680c267e 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 39) | 1 | SOURCE_FILE@[0; 94) |
2 | FN_DEF@[0; 38) | 2 | FN_DEF@[0; 93) |
3 | FN_KW@[0; 2) "fn" | 3 | FN_KW@[0; 2) "fn" |
4 | WHITESPACE@[2; 3) " " | 4 | WHITESPACE@[2; 3) " " |
5 | NAME@[3; 7) | 5 | NAME@[3; 7) |
@@ -8,8 +8,8 @@ SOURCE_FILE@[0; 39) | |||
8 | L_PAREN@[7; 8) "(" | 8 | L_PAREN@[7; 8) "(" |
9 | R_PAREN@[8; 9) ")" | 9 | R_PAREN@[8; 9) ")" |
10 | WHITESPACE@[9; 10) " " | 10 | WHITESPACE@[9; 10) " " |
11 | BLOCK_EXPR@[10; 38) | 11 | BLOCK_EXPR@[10; 93) |
12 | BLOCK@[10; 38) | 12 | BLOCK@[10; 93) |
13 | L_CURLY@[10; 11) "{" | 13 | L_CURLY@[10; 11) "{" |
14 | WHITESPACE@[11; 16) "\n " | 14 | WHITESPACE@[11; 16) "\n " |
15 | LET_STMT@[16; 36) | 15 | LET_STMT@[16; 36) |
@@ -37,6 +37,54 @@ SOURCE_FILE@[0; 39) | |||
37 | L_PAREN@[33; 34) "(" | 37 | L_PAREN@[33; 34) "(" |
38 | R_PAREN@[34; 35) ")" | 38 | R_PAREN@[34; 35) ")" |
39 | SEMI@[35; 36) ";" | 39 | SEMI@[35; 36) ";" |
40 | WHITESPACE@[36; 37) "\n" | 40 | WHITESPACE@[36; 41) "\n " |
41 | R_CURLY@[37; 38) "}" | 41 | LET_STMT@[41; 55) |
42 | WHITESPACE@[38; 39) "\n" | 42 | LET_KW@[41; 44) "let" |
43 | WHITESPACE@[44; 45) " " | ||
44 | TUPLE_PAT@[45; 49) | ||
45 | L_PAREN@[45; 46) "(" | ||
46 | BIND_PAT@[46; 47) | ||
47 | NAME@[46; 47) | ||
48 | IDENT@[46; 47) "a" | ||
49 | COMMA@[47; 48) "," | ||
50 | R_PAREN@[48; 49) ")" | ||
51 | WHITESPACE@[49; 50) " " | ||
52 | EQ@[50; 51) "=" | ||
53 | WHITESPACE@[51; 52) " " | ||
54 | TUPLE_EXPR@[52; 54) | ||
55 | L_PAREN@[52; 53) "(" | ||
56 | R_PAREN@[53; 54) ")" | ||
57 | SEMI@[54; 55) ";" | ||
58 | WHITESPACE@[55; 60) "\n " | ||
59 | LET_STMT@[60; 74) | ||
60 | LET_KW@[60; 63) "let" | ||
61 | WHITESPACE@[63; 64) " " | ||
62 | TUPLE_PAT@[64; 68) | ||
63 | L_PAREN@[64; 65) "(" | ||
64 | DOT_DOT_PAT@[65; 67) | ||
65 | DOTDOT@[65; 67) ".." | ||
66 | R_PAREN@[67; 68) ")" | ||
67 | WHITESPACE@[68; 69) " " | ||
68 | EQ@[69; 70) "=" | ||
69 | WHITESPACE@[70; 71) " " | ||
70 | TUPLE_EXPR@[71; 73) | ||
71 | L_PAREN@[71; 72) "(" | ||
72 | R_PAREN@[72; 73) ")" | ||
73 | SEMI@[73; 74) ";" | ||
74 | WHITESPACE@[74; 79) "\n " | ||
75 | LET_STMT@[79; 91) | ||
76 | LET_KW@[79; 82) "let" | ||
77 | WHITESPACE@[82; 83) " " | ||
78 | TUPLE_PAT@[83; 85) | ||
79 | L_PAREN@[83; 84) "(" | ||
80 | R_PAREN@[84; 85) ")" | ||
81 | WHITESPACE@[85; 86) " " | ||
82 | EQ@[86; 87) "=" | ||
83 | WHITESPACE@[87; 88) " " | ||
84 | TUPLE_EXPR@[88; 90) | ||
85 | L_PAREN@[88; 89) "(" | ||
86 | R_PAREN@[89; 90) ")" | ||
87 | SEMI@[90; 91) ";" | ||
88 | WHITESPACE@[91; 92) "\n" | ||
89 | R_CURLY@[92; 93) "}" | ||
90 | WHITESPACE@[93; 94) "\n" | ||