From ed8d5c86e3999aeec9a62e69ef065b2c799ecfa0 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 16 Jan 2020 23:37:43 +0800 Subject: Fix array element attribute position --- crates/ra_parser/src/grammar/expressions/atom.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'crates/ra_parser/src/grammar/expressions/atom.rs') diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 4ac1d6334..700994e80 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -192,9 +192,8 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { // 1, // 2, // ]; - attributes::outer_attributes(p); + attributes::with_outer_attributes(p, |p| expr(p).0); - expr(p); if p.eat(T![;]) { expr(p); p.expect(T![']']); @@ -212,12 +211,15 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { // #[cfg(test)] // 2, // ]; - attributes::outer_attributes(p); - if !p.at_ts(EXPR_FIRST) { - p.error("expected expression"); + if !attributes::with_outer_attributes(p, |p| { + if !p.at_ts(EXPR_FIRST) { + p.error("expected expression"); + return None; + } + expr(p).0 + }) { break; } - expr(p); } p.expect(T![']']); m.complete(p, ARRAY_EXPR) -- cgit v1.2.3