Replace contract_child to a less ad-hoc API

This commit is contained in:
pcpthm 2019-03-19 18:44:23 +09:00
parent e2ed813e89
commit 4cf179c089
2 changed files with 37 additions and 40 deletions

View file

@ -82,16 +82,15 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
};
let (cm, blocklike) = expr_stmt(p);
let kind = cm.as_ref().map(|cm| cm.kind()).unwrap_or(ERROR);
if let Some(cm) = &cm {
if has_attrs && !is_expr_stmt_attr_allowed(cm.kind()) {
// test_err attr_on_expr_not_allowed
// fn foo() {
// #[A] 1 + 2;
// #[B] if true {};
// }
p.error(format!("attributes are not allowed on {:?}", cm.kind()));
}
if has_attrs && !is_expr_stmt_attr_allowed(kind) {
// test_err attr_on_expr_not_allowed
// fn foo() {
// #[A] 1 + 2;
// #[B] if true {};
// }
p.error(format!("attributes are not allowed on {:?}", kind));
}
if p.at(R_CURLY) {
@ -101,7 +100,8 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
// #[B] &()
// }
if let Some(cm) = cm {
m.contract_child(p, cm);
cm.undo_completion(p).abandon(p);
m.complete(p, kind);
} else {
m.abandon(p);
}