mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Parse const effect block
This commit is contained in:
parent
03a9bbacf2
commit
2c94c4964a
4 changed files with 38 additions and 2 deletions
|
@ -46,6 +46,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
|
|||
T![continue],
|
||||
T![async],
|
||||
T![try],
|
||||
T![const],
|
||||
T![loop],
|
||||
T![for],
|
||||
LIFETIME_IDENT,
|
||||
|
@ -115,6 +116,14 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
|
|||
block_expr(p);
|
||||
m.complete(p, EFFECT_EXPR)
|
||||
}
|
||||
// test const_block
|
||||
// fn f() { const { } }
|
||||
T![const] if la == T!['{'] => {
|
||||
let m = p.start();
|
||||
p.bump(T![const]);
|
||||
block_expr(p);
|
||||
m.complete(p, EFFECT_EXPR)
|
||||
}
|
||||
T!['{'] => {
|
||||
// test for_range_from
|
||||
// fn foo() {
|
||||
|
|
|
@ -96,7 +96,10 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
let mut has_mods = false;
|
||||
|
||||
// modifiers
|
||||
has_mods |= p.eat(T![const]);
|
||||
if p.at(T![const]) && p.nth(1) != T!['{'] {
|
||||
p.eat(T![const]);
|
||||
has_mods = true;
|
||||
}
|
||||
|
||||
// test_err async_without_semicolon
|
||||
// fn foo() { let _ = async {} }
|
||||
|
@ -167,7 +170,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
m.complete(p, TRAIT);
|
||||
}
|
||||
|
||||
T![const] => {
|
||||
T![const] if p.nth(1) != T!['{'] => {
|
||||
consts::konst(p, m);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue