aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/expressions.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-18 04:16:20 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-18 04:16:20 +0000
commit4c1ea0b628f949612b48dd3b65c7d8bb2255f572 (patch)
treeb57d8b8b433fa06c9c6bd8795c2328507064e002 /crates/ra_parser/src/grammar/expressions.rs
parent40c6dd1f4c57d6a8ec26c1bdef24753c884c38aa (diff)
parent3d9c2beb8e0d4e0fbaded7dac259cadf7616a3ad (diff)
Merge #987
987: Refactor maybe_item to use Marker argument r=pcpthm a=pcpthm As suggested at <https://github.com/rust-analyzer/rust-analyzer/pull/980#issuecomment-473659745>. For expression paring functions, changing signature - from `fn(&mut Parser) -> Option<CompletedMarker>` to `fn(&mut Parser, Marker) -> Result<CompletedMarker, Marker>` - from `fn(&mut Parser) -> CompletedMarker` to `fn(&mut Parser, Marker) -> CompletedMarker` is my plan. Co-authored-by: pcpthm <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions.rs')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs70
1 files changed, 32 insertions, 38 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 5a3b9f589..ccbc905ab 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -62,47 +62,41 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
62 continue; 62 continue;
63 } 63 }
64 64
65 match items::maybe_item(p, items::ItemFlavor::Mod) { 65 let m = match items::maybe_item(p, m, items::ItemFlavor::Mod) {
66 items::MaybeItem::Item(kind) => { 66 Ok(()) => continue,
67 m.complete(p, kind); 67 Err(m) => m,
68 } 68 };
69 items::MaybeItem::Modifiers => { 69
70 // test pub_expr
71 // fn foo() { pub 92; } //FIXME
72 if has_attrs {
73 m.abandon(p);
74 p.error("expected a let statement or an item after attributes in block");
75 } else {
76 let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
77 if p.at(R_CURLY) {
70 m.abandon(p); 78 m.abandon(p);
71 p.error("expected an item"); 79 } else {
72 } 80 // test no_semi_after_block
73 // test pub_expr 81 // fn foo() {
74 // fn foo() { pub 92; } //FIXME 82 // if true {}
75 items::MaybeItem::None => { 83 // loop {}
76 if has_attrs { 84 // match () {}
77 m.abandon(p); 85 // while true {}
78 p.error("expected a let statement or an item after attributes in block"); 86 // for _ in () {}
87 // {}
88 // {}
89 // macro_rules! test {
90 // () => {}
91 // }
92 // test!{}
93 // }
94 if is_blocklike {
95 p.eat(SEMI);
79 } else { 96 } else {
80 let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block; 97 p.expect(SEMI);
81 if p.at(R_CURLY) {
82 m.abandon(p);
83 } else {
84 // test no_semi_after_block
85 // fn foo() {
86 // if true {}
87 // loop {}
88 // match () {}
89 // while true {}
90 // for _ in () {}
91 // {}
92 // {}
93 // macro_rules! test {
94 // () => {}
95 // }
96 // test!{}
97 // }
98 if is_blocklike {
99 p.eat(SEMI);
100 } else {
101 p.expect(SEMI);
102 }
103 m.complete(p, EXPR_STMT);
104 }
105 } 98 }
99 m.complete(p, EXPR_STMT);
106 } 100 }
107 } 101 }
108 } 102 }