simplify attribute parsing

This commit is contained in:
Aleksey Kladov 2021-09-25 18:07:51 +03:00
parent 13da3d93f9
commit 6997adfee7
2 changed files with 16 additions and 31 deletions

View file

@ -27,11 +27,7 @@ pub(super) fn expr_with_attrs(p: &mut Parser) -> bool {
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);
}
(true, Some(cm)) => cm.extend_to(p, m),
_ => m.abandon(p),
}
@ -92,11 +88,9 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) {
// { #[A] bar!()? }
// #[B] &()
// }
if let Some(cm) = cm {
cm.undo_completion(p).abandon(p);
m.complete(p, kind);
} else {
m.abandon(p);
match cm {
Some(cm) => cm.extend_to(p, m),
None => m.abandon(p),
}
} else {
// test no_semi_after_block