Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/patterns.rs')
| -rw-r--r-- | crates/parser/src/grammar/patterns.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 4dd44c030f..5726f085a0 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs @@ -199,6 +199,23 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) { } } +fn builtin_pat(p: &mut Parser<'_>) -> Option<CompletedMarker> { + let m = p.start(); + p.bump_remap(T![builtin]); + p.bump(T![#]); + if p.eat_contextual_kw(T![deref]) { + // test deref_pat + // fn foo() { let builtin # deref(_) = 1; } + p.expect(T!['(']); + pattern(p); + p.expect(T![')']); + Some(m.complete(p, DEREF_PAT)) + } else { + m.abandon(p); + None + } +} + const PAT_RECOVERY_SET: TokenSet = TokenSet::new(&[ T![let], T![if], @@ -214,6 +231,10 @@ const PAT_RECOVERY_SET: TokenSet = TokenSet::new(&[ ]); fn atom_pat(p: &mut Parser<'_>, recovery_set: TokenSet) -> Option<CompletedMarker> { + if p.at_contextual_kw(T![builtin]) && p.nth_at(1, T![#]) { + return builtin_pat(p); + } + let m = match p.current() { T![box] => box_pat(p), T![ref] | T![mut] => ident_pat(p, true), |