mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Parse do yeet
expressions
This commit is contained in:
parent
3033c3ddbf
commit
4a16afa264
7 changed files with 73 additions and 5 deletions
|
@ -48,6 +48,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
|
|||
T![unsafe],
|
||||
T![return],
|
||||
T![yield],
|
||||
T![do],
|
||||
T![break],
|
||||
T![continue],
|
||||
T![async],
|
||||
|
@ -93,6 +94,7 @@ pub(super) fn atom_expr(
|
|||
T![match] => match_expr(p),
|
||||
T![return] => return_expr(p),
|
||||
T![yield] => yield_expr(p),
|
||||
T![do] if p.nth_at_contextual_kw(1, T![yeet]) => yeet_expr(p),
|
||||
T![continue] => continue_expr(p),
|
||||
T![break] => break_expr(p, r),
|
||||
|
||||
|
@ -533,6 +535,7 @@ fn return_expr(p: &mut Parser<'_>) -> CompletedMarker {
|
|||
}
|
||||
m.complete(p, RETURN_EXPR)
|
||||
}
|
||||
|
||||
// test yield_expr
|
||||
// fn foo() {
|
||||
// yield;
|
||||
|
@ -548,6 +551,23 @@ fn yield_expr(p: &mut Parser<'_>) -> CompletedMarker {
|
|||
m.complete(p, YIELD_EXPR)
|
||||
}
|
||||
|
||||
// test yeet_expr
|
||||
// fn foo() {
|
||||
// do yeet;
|
||||
// do yeet 1
|
||||
// }
|
||||
fn yeet_expr(p: &mut Parser<'_>) -> CompletedMarker {
|
||||
assert!(p.at(T![do]));
|
||||
assert!(p.nth_at_contextual_kw(1, T![yeet]));
|
||||
let m = p.start();
|
||||
p.bump(T![do]);
|
||||
p.bump_remap(T![yeet]);
|
||||
if p.at_ts(EXPR_FIRST) {
|
||||
expr(p);
|
||||
}
|
||||
m.complete(p, YEET_EXPR)
|
||||
}
|
||||
|
||||
// test continue_expr
|
||||
// fn foo() {
|
||||
// loop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue