diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions.rs | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index 8dd9587d0..d27eb8b7e 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs | |||
@@ -45,10 +45,6 @@ pub(crate) fn block(p: &mut Parser) { | |||
45 | 45 | ||
46 | while !p.at(EOF) && !p.at(R_CURLY) { | 46 | while !p.at(EOF) && !p.at(R_CURLY) { |
47 | match p.current() { | 47 | match p.current() { |
48 | LET_KW => { | ||
49 | let m = p.start(); | ||
50 | let_stmt(p, m) | ||
51 | } | ||
52 | // test nocontentexpr | 48 | // test nocontentexpr |
53 | // fn foo(){ | 49 | // fn foo(){ |
54 | // ;;;some_expr();;;;{;;;};;;;Ok(()) | 50 | // ;;;some_expr();;;;{;;;};;;;Ok(()) |
@@ -60,49 +56,51 @@ pub(crate) fn block(p: &mut Parser) { | |||
60 | let m = p.start(); | 56 | let m = p.start(); |
61 | let has_attrs = p.at(POUND); | 57 | let has_attrs = p.at(POUND); |
62 | attributes::outer_attributes(p); | 58 | attributes::outer_attributes(p); |
63 | match items::maybe_item(p, items::ItemFlavor::Mod) { | 59 | if p.at(LET_KW) { |
64 | items::MaybeItem::Item(kind) => { | 60 | let_stmt(p, m); |
65 | m.complete(p, kind); | 61 | } else { |
66 | } | 62 | match items::maybe_item(p, items::ItemFlavor::Mod) { |
67 | items::MaybeItem::Modifiers => { | 63 | items::MaybeItem::Item(kind) => { |
68 | m.abandon(p); | 64 | m.complete(p, kind); |
69 | p.error("expected an item"); | 65 | } |
70 | } | 66 | items::MaybeItem::Modifiers => { |
71 | // test pub_expr | 67 | m.abandon(p); |
72 | // fn foo() { pub 92; } //FIXME | 68 | p.error("expected an item"); |
73 | items::MaybeItem::None => { | 69 | } |
74 | if has_attrs { | 70 | // test pub_expr |
75 | if p.at(LET_KW) { | 71 | // fn foo() { pub 92; } //FIXME |
76 | let_stmt(p, m); | 72 | items::MaybeItem::None => { |
77 | } else { | 73 | if has_attrs { |
78 | m.abandon(p); | ||
79 | p.error("expected a let statement"); | ||
80 | } | ||
81 | } else { | ||
82 | let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block; | ||
83 | if p.at(R_CURLY) { | ||
84 | m.abandon(p); | 74 | m.abandon(p); |
75 | p.error( | ||
76 | "expected a let statement or an item after attributes in block", | ||
77 | ); | ||
85 | } else { | 78 | } else { |
86 | // test no_semi_after_block | 79 | let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block; |
87 | // fn foo() { | 80 | if p.at(R_CURLY) { |
88 | // if true {} | 81 | m.abandon(p); |
89 | // loop {} | ||
90 | // match () {} | ||
91 | // while true {} | ||
92 | // for _ in () {} | ||
93 | // {} | ||
94 | // {} | ||
95 | // macro_rules! test { | ||
96 | // () => {} | ||
97 | // } | ||
98 | // test!{} | ||
99 | // } | ||
100 | if is_blocklike { | ||
101 | p.eat(SEMI); | ||
102 | } else { | 82 | } else { |
103 | p.expect(SEMI); | 83 | // test no_semi_after_block |
84 | // fn foo() { | ||
85 | // if true {} | ||
86 | // loop {} | ||
87 | // match () {} | ||
88 | // while true {} | ||
89 | // for _ in () {} | ||
90 | // {} | ||
91 | // {} | ||
92 | // macro_rules! test { | ||
93 | // () => {} | ||
94 | // } | ||
95 | // test!{} | ||
96 | // } | ||
97 | if is_blocklike { | ||
98 | p.eat(SEMI); | ||
99 | } else { | ||
100 | p.expect(SEMI); | ||
101 | } | ||
102 | m.complete(p, EXPR_STMT); | ||
104 | } | 103 | } |
105 | m.complete(p, EXPR_STMT); | ||
106 | } | 104 | } |
107 | } | 105 | } |
108 | } | 106 | } |