diff options
Diffstat (limited to 'crates/libsyntax2/src/grammar/items/mod.rs')
-rw-r--r-- | crates/libsyntax2/src/grammar/items/mod.rs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs index 18b681ee2..d236fb506 100644 --- a/crates/libsyntax2/src/grammar/items/mod.rs +++ b/crates/libsyntax2/src/grammar/items/mod.rs | |||
@@ -194,8 +194,8 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> { | |||
194 | // extern {} | 194 | // extern {} |
195 | EXTERN_KW if la == L_CURLY || ((la == STRING || la == RAW_STRING) && p.nth(2) == L_CURLY) => { | 195 | EXTERN_KW if la == L_CURLY || ((la == STRING || la == RAW_STRING) && p.nth(2) == L_CURLY) => { |
196 | abi(p); | 196 | abi(p); |
197 | extern_block(p); | 197 | extern_item_list(p); |
198 | EXTERN_BLOCK_EXPR | 198 | EXTERN_BLOCK |
199 | } | 199 | } |
200 | _ => return None, | 200 | _ => return None, |
201 | }; | 201 | }; |
@@ -212,10 +212,12 @@ fn extern_crate_item(p: &mut Parser) { | |||
212 | p.expect(SEMI); | 212 | p.expect(SEMI); |
213 | } | 213 | } |
214 | 214 | ||
215 | fn extern_block(p: &mut Parser) { | 215 | fn extern_item_list(p: &mut Parser) { |
216 | assert!(p.at(L_CURLY)); | 216 | assert!(p.at(L_CURLY)); |
217 | let m = p.start(); | ||
217 | p.bump(); | 218 | p.bump(); |
218 | p.expect(R_CURLY); | 219 | p.expect(R_CURLY); |
220 | m.complete(p, EXTERN_ITEM_LIST); | ||
219 | } | 221 | } |
220 | 222 | ||
221 | fn function(p: &mut Parser, flavor: ItemFlavor) { | 223 | fn function(p: &mut Parser, flavor: ItemFlavor) { |
@@ -284,14 +286,22 @@ fn mod_item(p: &mut Parser) { | |||
284 | p.bump(); | 286 | p.bump(); |
285 | 287 | ||
286 | name(p); | 288 | name(p); |
287 | if !p.eat(SEMI) { | 289 | if p.at(L_CURLY) { |
288 | if p.expect(L_CURLY) { | 290 | mod_item_list(p); |
289 | mod_contents(p, true); | 291 | } else if !p.eat(SEMI) { |
290 | p.expect(R_CURLY); | 292 | p.error("expected `;` or `{`"); |
291 | } | ||
292 | } | 293 | } |
293 | } | 294 | } |
294 | 295 | ||
296 | fn mod_item_list(p: &mut Parser) { | ||
297 | assert!(p.at(L_CURLY)); | ||
298 | let m = p.start(); | ||
299 | p.bump(); | ||
300 | mod_contents(p, true); | ||
301 | p.expect(R_CURLY); | ||
302 | m.complete(p, ITEM_LIST); | ||
303 | } | ||
304 | |||
295 | fn macro_call(p: &mut Parser) -> BlockLike { | 305 | fn macro_call(p: &mut Parser) -> BlockLike { |
296 | assert!(paths::is_path_start(p)); | 306 | assert!(paths::is_path_start(p)); |
297 | paths::use_path(p); | 307 | paths::use_path(p); |