diff options
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions/atom.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index 6d6d89f70..600774afd 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs | |||
@@ -360,8 +360,8 @@ fn match_arm(p: &mut Parser) -> BlockLike { | |||
360 | while p.eat(PIPE) { | 360 | while p.eat(PIPE) { |
361 | patterns::pattern(p); | 361 | patterns::pattern(p); |
362 | } | 362 | } |
363 | if p.eat(IF_KW) { | 363 | if p.at(IF_KW) { |
364 | expr(p); | 364 | match_guard(p); |
365 | } | 365 | } |
366 | p.expect(FAT_ARROW); | 366 | p.expect(FAT_ARROW); |
367 | let ret = expr_stmt(p); | 367 | let ret = expr_stmt(p); |
@@ -369,6 +369,20 @@ fn match_arm(p: &mut Parser) -> BlockLike { | |||
369 | ret | 369 | ret |
370 | } | 370 | } |
371 | 371 | ||
372 | // test match_guard | ||
373 | // fn foo() { | ||
374 | // match () { | ||
375 | // _ if foo => (), | ||
376 | // } | ||
377 | // } | ||
378 | fn match_guard(p: &mut Parser) -> CompletedMarker { | ||
379 | assert!(p.at(IF_KW)); | ||
380 | let m = p.start(); | ||
381 | p.bump(); | ||
382 | expr(p); | ||
383 | m.complete(p, MATCH_GUARD) | ||
384 | } | ||
385 | |||
372 | // test block_expr | 386 | // test block_expr |
373 | // fn foo() { | 387 | // fn foo() { |
374 | // {}; | 388 | // {}; |