diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-16 15:49:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-16 15:49:23 +0000 |
commit | e614356de10256c64e02f5d0f82cfa39e27b0f07 (patch) | |
tree | 1ad38d73f8cac5a82e1cb9493016b645a335074a /crates/ra_parser/src/grammar/expressions | |
parent | f4eeff2c82e7d8b95706c2bcb0388eeeb3ddd24e (diff) | |
parent | a766883a751096e5b912b59a14d7b6fc3372c791 (diff) |
Merge #2827
2827: Fix array element attribute position r=matklad a=edwin0cheng
This PR fixed a bug which an ATTR node insert in the wrong place in array element. ~~And introduce `precede_next` for allow outer attributes to insert into a parsed `expr`.~~
related #2783
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 14 |
1 files changed, 8 insertions, 6 deletions
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 { | |||
192 | // 1, | 192 | // 1, |
193 | // 2, | 193 | // 2, |
194 | // ]; | 194 | // ]; |
195 | attributes::outer_attributes(p); | 195 | attributes::with_outer_attributes(p, |p| expr(p).0); |
196 | 196 | ||
197 | expr(p); | ||
198 | if p.eat(T![;]) { | 197 | if p.eat(T![;]) { |
199 | expr(p); | 198 | expr(p); |
200 | p.expect(T![']']); | 199 | p.expect(T![']']); |
@@ -212,12 +211,15 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { | |||
212 | // #[cfg(test)] | 211 | // #[cfg(test)] |
213 | // 2, | 212 | // 2, |
214 | // ]; | 213 | // ]; |
215 | attributes::outer_attributes(p); | 214 | if !attributes::with_outer_attributes(p, |p| { |
216 | if !p.at_ts(EXPR_FIRST) { | 215 | if !p.at_ts(EXPR_FIRST) { |
217 | p.error("expected expression"); | 216 | p.error("expected expression"); |
217 | return None; | ||
218 | } | ||
219 | expr(p).0 | ||
220 | }) { | ||
218 | break; | 221 | break; |
219 | } | 222 | } |
220 | expr(p); | ||
221 | } | 223 | } |
222 | p.expect(T![']']); | 224 | p.expect(T![']']); |
223 | m.complete(p, ARRAY_EXPR) | 225 | m.complete(p, ARRAY_EXPR) |