diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-17 18:39:26 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-17 18:39:26 +0000 |
commit | 646b53ace30660935641932c043301e3cdd4e71f (patch) | |
tree | 42f94aa460aa4233ad4372044faa6e2a27842ed1 /crates/ra_syntax/src/grammar/expressions/atom.rs | |
parent | 3dcde0b2ab8bc28dc8ef98ec07cb6d1072b93de8 (diff) | |
parent | bb259587056faa3a76eed6e7dae487e1848d841a (diff) |
Merge #846
846: WIP: Enable parsing of attributes inside a match block r=matklad a=vipentti
We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.
Instead we run validation on `MatchArmList` to allow better reporting of errors.
This fixes #845 and works towards #759
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/grammar/expressions/atom.rs')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions/atom.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index 27ba87657..e74305b6a 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs | |||
@@ -313,11 +313,39 @@ pub(crate) fn match_arm_list(p: &mut Parser) { | |||
313 | assert!(p.at(L_CURLY)); | 313 | assert!(p.at(L_CURLY)); |
314 | let m = p.start(); | 314 | let m = p.start(); |
315 | p.eat(L_CURLY); | 315 | p.eat(L_CURLY); |
316 | |||
317 | // test match_arms_inner_attribute | ||
318 | // fn foo() { | ||
319 | // match () { | ||
320 | // #![doc("Inner attribute")] | ||
321 | // #![doc("Can be")] | ||
322 | // #![doc("Stacked")] | ||
323 | // _ => (), | ||
324 | // } | ||
325 | // } | ||
326 | attributes::inner_attributes(p); | ||
327 | |||
316 | while !p.at(EOF) && !p.at(R_CURLY) { | 328 | while !p.at(EOF) && !p.at(R_CURLY) { |
317 | if p.at(L_CURLY) { | 329 | if p.at(L_CURLY) { |
318 | error_block(p, "expected match arm"); | 330 | error_block(p, "expected match arm"); |
319 | continue; | 331 | continue; |
320 | } | 332 | } |
333 | |||
334 | // test match_arms_outer_attributes | ||
335 | // fn foo() { | ||
336 | // match () { | ||
337 | // #[cfg(feature = "some")] | ||
338 | // _ => (), | ||
339 | // #[cfg(feature = "other")] | ||
340 | // _ => (), | ||
341 | // #[cfg(feature = "many")] | ||
342 | // #[cfg(feature = "attributes")] | ||
343 | // #[cfg(feature = "before")] | ||
344 | // _ => (), | ||
345 | // } | ||
346 | // } | ||
347 | attributes::outer_attributes(p); | ||
348 | |||
321 | // test match_arms_commas | 349 | // test match_arms_commas |
322 | // fn foo() { | 350 | // fn foo() { |
323 | // match () { | 351 | // match () { |