diff options
Diffstat (limited to 'crates/ra_syntax')
3 files changed, 51 insertions, 33 deletions
diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs index 64cdf0b1b..692ffbb8c 100644 --- a/crates/ra_syntax/src/grammar/patterns.rs +++ b/crates/ra_syntax/src/grammar/patterns.rs | |||
@@ -48,11 +48,16 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { | |||
48 | // test literal_pattern | 48 | // test literal_pattern |
49 | // fn main() { | 49 | // fn main() { |
50 | // match () { | 50 | // match () { |
51 | // -1 => (), | ||
51 | // 92 => (), | 52 | // 92 => (), |
52 | // 'c' => (), | 53 | // 'c' => (), |
53 | // "hello" => (), | 54 | // "hello" => (), |
54 | // } | 55 | // } |
55 | // } | 56 | // } |
57 | if p.at(MINUS) && (p.nth(1) == INT_NUMBER || p.nth(1) == FLOAT_NUMBER) { | ||
58 | p.bump(); | ||
59 | } | ||
60 | |||
56 | if let Some(m) = expressions::literal(p) { | 61 | if let Some(m) = expressions::literal(p) { |
57 | return Some(m); | 62 | return Some(m); |
58 | } | 63 | } |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.rs index 16f674d9d..6dfd67b4c 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | fn main() { | 1 | fn main() { |
2 | match () { | 2 | match () { |
3 | -1 => (), | ||
3 | 92 => (), | 4 | 92 => (), |
4 | 'c' => (), | 5 | 'c' => (), |
5 | "hello" => (), | 6 | "hello" => (), |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.txt index 99b289d56..71d62eaba 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0055_literal_pattern.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 95) | 1 | SOURCE_FILE@[0; 113) |
2 | FN_DEF@[0; 94) | 2 | FN_DEF@[0; 112) |
3 | FN_KW@[0; 2) | 3 | FN_KW@[0; 2) |
4 | WHITESPACE@[2; 3) | 4 | WHITESPACE@[2; 3) |
5 | NAME@[3; 7) | 5 | NAME@[3; 7) |
@@ -8,22 +8,23 @@ SOURCE_FILE@[0; 95) | |||
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@[10; 94) | 11 | BLOCK@[10; 112) |
12 | L_CURLY@[10; 11) | 12 | L_CURLY@[10; 11) |
13 | WHITESPACE@[11; 16) | 13 | WHITESPACE@[11; 16) |
14 | MATCH_EXPR@[16; 92) | 14 | MATCH_EXPR@[16; 110) |
15 | MATCH_KW@[16; 21) | 15 | MATCH_KW@[16; 21) |
16 | WHITESPACE@[21; 22) | 16 | WHITESPACE@[21; 22) |
17 | TUPLE_EXPR@[22; 24) | 17 | TUPLE_EXPR@[22; 24) |
18 | L_PAREN@[22; 23) | 18 | L_PAREN@[22; 23) |
19 | R_PAREN@[23; 24) | 19 | R_PAREN@[23; 24) |
20 | WHITESPACE@[24; 25) | 20 | WHITESPACE@[24; 25) |
21 | MATCH_ARM_LIST@[25; 92) | 21 | MATCH_ARM_LIST@[25; 110) |
22 | L_CURLY@[25; 26) | 22 | L_CURLY@[25; 26) |
23 | WHITESPACE@[26; 35) | 23 | WHITESPACE@[26; 35) |
24 | MATCH_ARM@[35; 43) | 24 | MATCH_ARM@[35; 43) |
25 | LITERAL@[35; 37) | 25 | MINUS@[35; 36) |
26 | INT_NUMBER@[35; 37) "92" | 26 | LITERAL@[36; 37) |
27 | INT_NUMBER@[36; 37) "1" | ||
27 | WHITESPACE@[37; 38) | 28 | WHITESPACE@[37; 38) |
28 | FAT_ARROW@[38; 40) | 29 | FAT_ARROW@[38; 40) |
29 | WHITESPACE@[40; 41) | 30 | WHITESPACE@[40; 41) |
@@ -32,29 +33,40 @@ SOURCE_FILE@[0; 95) | |||
32 | R_PAREN@[42; 43) | 33 | R_PAREN@[42; 43) |
33 | COMMA@[43; 44) | 34 | COMMA@[43; 44) |
34 | WHITESPACE@[44; 53) | 35 | WHITESPACE@[44; 53) |
35 | MATCH_ARM@[53; 62) | 36 | MATCH_ARM@[53; 61) |
36 | LITERAL@[53; 56) | 37 | LITERAL@[53; 55) |
37 | CHAR@[53; 56) | 38 | INT_NUMBER@[53; 55) "92" |
38 | WHITESPACE@[56; 57) | 39 | WHITESPACE@[55; 56) |
39 | FAT_ARROW@[57; 59) | 40 | FAT_ARROW@[56; 58) |
40 | WHITESPACE@[59; 60) | 41 | WHITESPACE@[58; 59) |
41 | TUPLE_EXPR@[60; 62) | 42 | TUPLE_EXPR@[59; 61) |
42 | L_PAREN@[60; 61) | 43 | L_PAREN@[59; 60) |
43 | R_PAREN@[61; 62) | 44 | R_PAREN@[60; 61) |
44 | COMMA@[62; 63) | 45 | COMMA@[61; 62) |
45 | WHITESPACE@[63; 72) | 46 | WHITESPACE@[62; 71) |
46 | MATCH_ARM@[72; 85) | 47 | MATCH_ARM@[71; 80) |
47 | LITERAL@[72; 79) | 48 | LITERAL@[71; 74) |
48 | STRING@[72; 79) | 49 | CHAR@[71; 74) |
49 | WHITESPACE@[79; 80) | 50 | WHITESPACE@[74; 75) |
50 | FAT_ARROW@[80; 82) | 51 | FAT_ARROW@[75; 77) |
51 | WHITESPACE@[82; 83) | 52 | WHITESPACE@[77; 78) |
52 | TUPLE_EXPR@[83; 85) | 53 | TUPLE_EXPR@[78; 80) |
53 | L_PAREN@[83; 84) | 54 | L_PAREN@[78; 79) |
54 | R_PAREN@[84; 85) | 55 | R_PAREN@[79; 80) |
55 | COMMA@[85; 86) | 56 | COMMA@[80; 81) |
56 | WHITESPACE@[86; 91) | 57 | WHITESPACE@[81; 90) |
57 | R_CURLY@[91; 92) | 58 | MATCH_ARM@[90; 103) |
58 | WHITESPACE@[92; 93) | 59 | LITERAL@[90; 97) |
59 | R_CURLY@[93; 94) | 60 | STRING@[90; 97) |
60 | WHITESPACE@[94; 95) | 61 | WHITESPACE@[97; 98) |
62 | FAT_ARROW@[98; 100) | ||
63 | WHITESPACE@[100; 101) | ||
64 | TUPLE_EXPR@[101; 103) | ||
65 | L_PAREN@[101; 102) | ||
66 | R_PAREN@[102; 103) | ||
67 | COMMA@[103; 104) | ||
68 | WHITESPACE@[104; 109) | ||
69 | R_CURLY@[109; 110) | ||
70 | WHITESPACE@[110; 111) | ||
71 | R_CURLY@[111; 112) | ||
72 | WHITESPACE@[112; 113) | ||