From 4cf179c089aeed381cd67bcd265e76a27f11facd Mon Sep 17 00:00:00 2001 From: pcpthm Date: Tue, 19 Mar 2019 18:44:23 +0900 Subject: Replace `contract_child` to a less ad-hoc API --- crates/ra_parser/src/grammar/expressions.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_parser/src/grammar') diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index c8ce07179..73e1acd5a 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -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); } -- cgit v1.2.3