aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/expressions.rs
diff options
context:
space:
mode:
authorpcpthm <[email protected]>2019-03-19 09:44:23 +0000
committerpcpthm <[email protected]>2019-03-19 09:44:23 +0000
commit4cf179c089aeed381cd67bcd265e76a27f11facd (patch)
treea47ced34b0861ba6179f6644e5284eac628301c4 /crates/ra_parser/src/grammar/expressions.rs
parente2ed813e8951517f59552323c55a0ff05167c945 (diff)
Replace `contract_child` to a less ad-hoc API
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions.rs')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs20
1 files changed, 10 insertions, 10 deletions
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) {
82 }; 82 };
83 83
84 let (cm, blocklike) = expr_stmt(p); 84 let (cm, blocklike) = expr_stmt(p);
85 let kind = cm.as_ref().map(|cm| cm.kind()).unwrap_or(ERROR);
85 86
86 if let Some(cm) = &cm { 87 if has_attrs && !is_expr_stmt_attr_allowed(kind) {
87 if has_attrs && !is_expr_stmt_attr_allowed(cm.kind()) { 88 // test_err attr_on_expr_not_allowed
88 // test_err attr_on_expr_not_allowed 89 // fn foo() {
89 // fn foo() { 90 // #[A] 1 + 2;
90 // #[A] 1 + 2; 91 // #[B] if true {};
91 // #[B] if true {}; 92 // }
92 // } 93 p.error(format!("attributes are not allowed on {:?}", kind));
93 p.error(format!("attributes are not allowed on {:?}", cm.kind()));
94 }
95 } 94 }
96 95
97 if p.at(R_CURLY) { 96 if p.at(R_CURLY) {
@@ -101,7 +100,8 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
101 // #[B] &() 100 // #[B] &()
102 // } 101 // }
103 if let Some(cm) = cm { 102 if let Some(cm) = cm {
104 m.contract_child(p, cm); 103 cm.undo_completion(p).abandon(p);
104 m.complete(p, kind);
105 } else { 105 } else {
106 m.abandon(p); 106 m.abandon(p);
107 } 107 }