aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/paths.rs2
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast74
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast38
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs1
5 files changed, 82 insertions, 41 deletions
diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs
index 332acc1a0..428aa711e 100644
--- a/crates/ra_parser/src/grammar/paths.rs
+++ b/crates/ra_parser/src/grammar/paths.rs
@@ -3,7 +3,7 @@
3use super::*; 3use super::*;
4 4
5pub(super) const PATH_FIRST: TokenSet = 5pub(super) const PATH_FIRST: TokenSet =
6 token_set![IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLON, L_ANGLE]; 6 token_set![IDENT, T![self], T![super], T![crate], T![:], T![<]];
7 7
8pub(super) fn is_path_start(p: &Parser) -> bool { 8pub(super) fn is_path_start(p: &Parser) -> bool {
9 is_use_path_start(p) || p.at(T![<]) 9 is_use_path_start(p) || p.at(T![<])
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index 68fb2fc73..427c0eb49 100644
--- a/crates/ra_parser/src/grammar/patterns.rs
+++ b/crates/ra_parser/src/grammar/patterns.rs
@@ -4,7 +4,7 @@ use super::*;
4 4
5pub(super) const PATTERN_FIRST: TokenSet = expressions::LITERAL_FIRST 5pub(super) const PATTERN_FIRST: TokenSet = expressions::LITERAL_FIRST
6 .union(paths::PATH_FIRST) 6 .union(paths::PATH_FIRST)
7 .union(token_set![BOX_KW, REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP, UNDERSCORE, MINUS, DOT]); 7 .union(token_set![T![box], T![ref], T![mut], T!['('], T!['['], T![&], T![_], T![-], T![.]]);
8 8
9pub(crate) fn pattern(p: &mut Parser) { 9pub(crate) fn pattern(p: &mut Parser) {
10 pattern_r(p, PAT_RECOVERY_SET); 10 pattern_r(p, PAT_RECOVERY_SET);
@@ -88,7 +88,9 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
88 _ => bind_pat(p, true), 88 _ => bind_pat(p, true),
89 }, 89 },
90 90
91 _ if paths::is_use_path_start(p) => path_or_macro_pat(p), 91 // test type_path_in_pattern
92 // fn main() { let <_>::Foo = (); }
93 _ if paths::is_path_start(p) => path_or_macro_pat(p),
92 _ if is_literal_pat_start(p) => literal_pat(p), 94 _ if is_literal_pat_start(p) => literal_pat(p),
93 95
94 T![.] if p.at(T![..]) => dot_dot_pat(p), 96 T![.] if p.at(T![..]) => dot_dot_pat(p),
@@ -138,7 +140,7 @@ fn literal_pat(p: &mut Parser) -> CompletedMarker {
138// let Bar(..) = (); 140// let Bar(..) = ();
139// } 141// }
140fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker { 142fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker {
141 assert!(paths::is_use_path_start(p)); 143 assert!(paths::is_path_start(p));
142 let m = p.start(); 144 let m = p.start();
143 paths::expr_path(p); 145 paths::expr_path(p);
144 let kind = match p.current() { 146 let kind = match p.current() {
diff --git a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast b/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast
index 7c957fdde..48610a5eb 100644
--- a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast
+++ b/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast
@@ -180,44 +180,45 @@ [email protected]
180 [email protected] 180 [email protected]
181 [email protected] 181 [email protected]
182 [email protected] "(" 182 [email protected] "("
183 [email protected] 183 [email protected]
184 [email protected] 184 [email protected] "for"
185 [email protected] 185 [email protected]
186 [email protected] 186 [email protected]
187 [email protected] 187 [email protected]
188 [email protected] 188 [email protected] "<"
189 [email protected] "for" 189 [email protected]
190 [email protected] 190 [email protected] "\'a"
191 [email protected] "<" 191 [email protected] ">"
192 [email protected] 192 [email protected] " "
193 [email protected] "\'a" 193 [email protected]
194 [email protected] ">" 194 [email protected]
195 [email protected] " " 195 [email protected]
196 [email protected]
196 [email protected] 197 [email protected]
197 [email protected] 198 [email protected]
198 [email protected] 199 [email protected]
199 [email protected] 200 [email protected]
200 [email protected] "Trait" 201 [email protected] "Trait"
201 [email protected] "<" 202 [email protected] "<"
202 [email protected] 203 [email protected]
203 [email protected] "\'a" 204 [email protected] "\'a"
204 [email protected] ">" 205 [email protected] ">"
205 [email protected] 206 [email protected]
206 [email protected] ")" 207 [email protected] ")"
207 [email protected] " " 208 [email protected] " "
208 [email protected] "+" 209 [email protected] "+"
209 [email protected] " " 210 [email protected] " "
210 [email protected] 211 [email protected]
211 [email protected] "(" 212 [email protected] "("
212 [email protected] 213 [email protected]
213 [email protected] 214 [email protected]
214 [email protected] 215 [email protected]
215 [email protected] 216 [email protected]
216 [email protected] "Copy" 217 [email protected] "Copy"
217 [email protected] ")" 218 [email protected] ")"
218 [email protected] ">" 219 [email protected] ">"
219 [email protected] 220 [email protected]
220 [email protected] ";" 221 [email protected] ";"
221 [email protected] "\n " 222 [email protected] "\n "
222 [email protected] 223 [email protected]
223 [email protected] "let" 224 [email protected] "let"
@@ -302,13 +303,12 @@ error 146..146: expected expression
302error 147..147: expected SEMICOLON 303error 147..147: expected SEMICOLON
303error 148..148: expected expression 304error 148..148: expected expression
304error 149..149: expected SEMICOLON 305error 149..149: expected SEMICOLON
305error 154..154: expected pattern 306error 155..155: expected type
306error 155..155: expected IN_KW 307error 158..158: expected IN_KW
307error 155..155: expected expression
308error 157..157: expected a block
309error 165..165: expected expression 308error 165..165: expected expression
310error 168..168: expected expression 309error 168..168: expected expression
311error 179..179: expected expression 310error 179..179: expected expression
311error 180..180: expected a block
312error 180..180: expected COMMA 312error 180..180: expected COMMA
313error 180..180: expected expression 313error 180..180: expected expression
314error 180..180: expected R_PAREN 314error 180..180: expected R_PAREN
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast b/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast
new file mode 100644
index 000000000..868899275
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast
@@ -0,0 +1,38 @@
1[email protected]
2 [email protected]
3 [email protected] "fn"
4 [email protected] " "
5 [email protected]
6 [email protected] "main"
7 [email protected]
8 [email protected] "("
9 [email protected] ")"
10 [email protected] " "
11 [email protected]
12 [email protected] "{"
13 [email protected] " "
14 [email protected]
15 [email protected] "let"
16 [email protected] " "
17 [email protected]
18 [email protected]
19 [email protected]
20 [email protected]
21 [email protected] "<"
22 [email protected]
23 [email protected] "_"
24 [email protected] ">"
25 [email protected] "::"
26 [email protected]
27 [email protected]
28 [email protected] "Foo"
29 [email protected] " "
30 [email protected] "="
31 [email protected] " "
32 [email protected]
33 [email protected] "("
34 [email protected] ")"
35 [email protected] ";"
36 [email protected] " "
37 [email protected] "}"
38 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs b/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs
new file mode 100644
index 000000000..ebe26834d
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs
@@ -0,0 +1 @@
fn main() { let <_>::Foo = (); }