Skip to content

Commit e8d5057

Browse files
committed
Correctly parse <_> paths in patterns
closes #3659
1 parent 16943e5 commit e8d5057

File tree

4 files changed

+80
-39
lines changed

4 files changed

+80
-39
lines changed

crates/ra_parser/src/grammar/patterns.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
8888
_ => bind_pat(p, true),
8989
},
9090

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),
9294
_ if is_literal_pat_start(p) => literal_pat(p),
9395

9496
T![.] if p.at(T![..]) => dot_dot_pat(p),
@@ -138,7 +140,7 @@ fn literal_pat(p: &mut Parser) -> CompletedMarker {
138140
// let Bar(..) = ();
139141
// }
140142
fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker {
141-
assert!(paths::is_use_path_start(p));
143+
assert!(paths::is_path_start(p));
142144
let m = p.start();
143145
paths::expr_path(p);
144146
let kind = match p.current() {

crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -180,44 +180,45 @@ [email protected]
180180
181181
182182
183-
184-
185-
186-
187-
188-
189-
190-
191-
192-
193-
194-
195-
183+
184+
185+
186+
187+
188+
189+
190+
191+
192+
193+
194+
195+
196+
196197
197198
198199
199200
200201
201-
202-
203-
204-
205-
206-
207-
208-
209-
210-
211-
212-
213-
214-
215-
216-
217-
218-
219-
220-
202+
203+
204+
205+
206+
207+
208+
209+
210+
211+
212+
213+
214+
215+
216+
217+
218+
219+
220+
221+
221222
222223
223224
@@ -302,13 +303,12 @@ error 146..146: expected expression
302303
error 147..147: expected SEMICOLON
303304
error 148..148: expected expression
304305
error 149..149: expected SEMICOLON
305-
error 154..154: expected pattern
306-
error 155..155: expected IN_KW
307-
error 155..155: expected expression
308-
error 157..157: expected a block
306+
error 155..155: expected type
307+
error 158..158: expected IN_KW
309308
error 165..165: expected expression
310309
error 168..168: expected expression
311310
error 179..179: expected expression
311+
error 180..180: expected a block
312312
error 180..180: expected COMMA
313313
error 180..180: expected expression
314314
error 180..180: expected R_PAREN
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() { let <_>::Foo = (); }

0 commit comments

Comments
 (0)