mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Extract expr_with_attrs
This commit is contained in:
parent
90b8a31b83
commit
b7c45fba57
3 changed files with 36 additions and 23 deletions
|
@ -19,6 +19,26 @@ pub(super) fn expr(p: &mut Parser) -> (Option<CompletedMarker>, BlockLike) {
|
|||
expr_bp(p, r, 1)
|
||||
}
|
||||
|
||||
pub(super) fn expr_with_attrs(p: &mut Parser) -> bool {
|
||||
let m = p.start();
|
||||
let has_attrs = p.at(T![#]);
|
||||
attributes::outer_attributes(p);
|
||||
|
||||
let (cm, _block_like) = expr(p);
|
||||
let success = cm.is_some();
|
||||
|
||||
match (has_attrs, cm) {
|
||||
(true, Some(cm)) => {
|
||||
let kind = cm.kind();
|
||||
cm.undo_completion(p).abandon(p);
|
||||
m.complete(p, kind);
|
||||
}
|
||||
_ => m.abandon(p),
|
||||
}
|
||||
|
||||
success
|
||||
}
|
||||
|
||||
pub(super) fn expr_stmt(p: &mut Parser) -> (Option<CompletedMarker>, BlockLike) {
|
||||
let r = Restrictions { forbid_structs: false, prefer_stmt: true };
|
||||
expr_bp(p, r, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue