aboutsummaryrefslogtreecommitdiff
path: root/crates/parser
diff options
context:
space:
mode:
Diffstat (limited to 'crates/parser')
-rw-r--r--crates/parser/src/grammar/patterns.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 7e7f73dee..44400c9f8 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -1,5 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use expressions::block_expr;
4
3use super::*; 5use super::*;
4 6
5pub(super) const PATTERN_FIRST: TokenSet = 7pub(super) const PATTERN_FIRST: TokenSet =
@@ -89,6 +91,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
89 let m = match p.nth(0) { 91 let m = match p.nth(0) {
90 T![box] => box_pat(p), 92 T![box] => box_pat(p),
91 T![ref] | T![mut] => ident_pat(p, true), 93 T![ref] | T![mut] => ident_pat(p, true),
94 T![const] => const_block_pat(p),
92 IDENT => match p.nth(1) { 95 IDENT => match p.nth(1) {
93 // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro 96 // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro
94 // (T![x]). 97 // (T![x]).
@@ -386,3 +389,16 @@ fn box_pat(p: &mut Parser) -> CompletedMarker {
386 pattern_single(p); 389 pattern_single(p);
387 m.complete(p, BOX_PAT) 390 m.complete(p, BOX_PAT)
388} 391}
392
393// test const_block_pat
394// fn main() {
395// let const { 15 } = ();
396// let const { foo(); bar() } = ();
397// }
398fn const_block_pat(p: &mut Parser) -> CompletedMarker {
399 assert!(p.at(T![const]));
400 let m = p.start();
401 p.bump(T![const]);
402 block_expr(p);
403 m.complete(p, CONST_BLOCK_PAT)
404}