mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Parse ConstBlockPat
This commit is contained in:
parent
be7260485e
commit
03a9bbacf2
3 changed files with 96 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
//! FIXME: write short doc here
|
||||
|
||||
use expressions::block_expr;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub(super) const PATTERN_FIRST: TokenSet =
|
||||
|
@ -89,6 +91,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
|
|||
let m = match p.nth(0) {
|
||||
T![box] => box_pat(p),
|
||||
T![ref] | T![mut] => ident_pat(p, true),
|
||||
T![const] => const_block_pat(p),
|
||||
IDENT => match p.nth(1) {
|
||||
// Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro
|
||||
// (T![x]).
|
||||
|
@ -386,3 +389,16 @@ fn box_pat(p: &mut Parser) -> CompletedMarker {
|
|||
pattern_single(p);
|
||||
m.complete(p, BOX_PAT)
|
||||
}
|
||||
|
||||
// test const_block_pat
|
||||
// fn main() {
|
||||
// let const { 15 } = ();
|
||||
// let const { foo(); bar() } = ();
|
||||
// }
|
||||
fn const_block_pat(p: &mut Parser) -> CompletedMarker {
|
||||
assert!(p.at(T![const]));
|
||||
let m = p.start();
|
||||
p.bump(T![const]);
|
||||
block_expr(p);
|
||||
m.complete(p, CONST_BLOCK_PAT)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue