diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-28 13:14:19 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-28 13:14:19 +0100 |
commit | 5d829841cdab630d7953defd12e024e46ecc7c4f (patch) | |
tree | f5c8bf7d4f4958ea6a489b187df0ea4f1da41464 /crates/ra_parser/src/grammar | |
parent | e8dc92ca734e34b25291015008d5c6dfd933fa7a (diff) | |
parent | de930237ffb5bec9489443477a5b4ff964f56b0e (diff) |
Merge #1440
1440: fixed #1384 r=matklad a=zbelial
This PR fixed #1384 .
Co-authored-by: zjy <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 11 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 16 |
2 files changed, 20 insertions, 7 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 795dccea1..298030cb9 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -181,6 +181,17 @@ pub(crate) fn expr_block_contents(p: &mut Parser) { | |||
181 | // fn foo(){ | 181 | // fn foo(){ |
182 | // ;;;some_expr();;;;{;;;};;;;Ok(()) | 182 | // ;;;some_expr();;;;{;;;};;;;Ok(()) |
183 | // } | 183 | // } |
184 | |||
185 | // test nocontentexpr_after_item | ||
186 | // fn simple_function() { | ||
187 | // enum LocalEnum { | ||
188 | // One, | ||
189 | // Two, | ||
190 | // }; | ||
191 | // fn f() {}; | ||
192 | // struct S {}; | ||
193 | // } | ||
194 | |||
184 | if p.current() == T![;] { | 195 | if p.current() == T![;] { |
185 | p.bump(); | 196 | p.bump(); |
186 | continue; | 197 | continue; |
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index 424d0476d..543af7c4b 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -38,7 +38,15 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF | |||
38 | let m = p.start(); | 38 | let m = p.start(); |
39 | attributes::outer_attributes(p); | 39 | attributes::outer_attributes(p); |
40 | let m = match maybe_item(p, m, flavor) { | 40 | let m = match maybe_item(p, m, flavor) { |
41 | Ok(()) => return, | 41 | Ok(()) => { |
42 | if p.at(T![;]) { | ||
43 | p.err_and_bump( | ||
44 | "expected item, found `;`\n\ | ||
45 | consider removing this semicolon", | ||
46 | ); | ||
47 | } | ||
48 | return; | ||
49 | } | ||
42 | Err(m) => m, | 50 | Err(m) => m, |
43 | }; | 51 | }; |
44 | if paths::is_path_start(p) { | 52 | if paths::is_path_start(p) { |
@@ -263,12 +271,6 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
263 | } | 271 | } |
264 | _ => return Err(m), | 272 | _ => return Err(m), |
265 | }; | 273 | }; |
266 | if p.at(T![;]) { | ||
267 | p.err_and_bump( | ||
268 | "expected item, found `;`\n\ | ||
269 | consider removing this semicolon", | ||
270 | ); | ||
271 | } | ||
272 | Ok(()) | 274 | Ok(()) |
273 | } | 275 | } |
274 | 276 | ||