diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-19 10:36:17 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-19 10:36:17 +0000 |
commit | 5b6ad0971c050981deb10c56ad2634293f104228 (patch) | |
tree | 7f76ce1da6ed9e245f5b4ef14257418c66f59577 /crates/ra_parser/src/lib.rs | |
parent | 91576afc7e64f11dde2bed14b578e4914d253a6a (diff) | |
parent | 4cf179c089aeed381cd67bcd265e76a27f11facd (diff) |
Merge #996
996: Allow attributes on top level expressions r=matklad a=pcpthm
This PR modifies parser to allow outer attributes on top level expression. Here, top level expression means either
- Expression statement e.g. `foo();`
- Last expression in a block without semicolon `bar()` in `{ foo(); bar() }`.
Except for binary operation expressions and `if` expressions, which are errors (feature gated) in rustc.
Attributes on inner expressions like `foo(#[a] 1)` are not implemented.
I first tried to implement this by passing `Maker` to expression parsers. However, this implementation couldn't parse `#[attr] foo()` correctly as `CallExpr(Attr(..), PathExpr(..), ArgList(..))` and instead parsed incorrectly as `CallExpr(PathExpr(Attr(..), ..), ArgList(..))` due to the way left recursion is handled.
In the end, I introduce `undo_completion` method. Which is not the suggested approach, but it seems not very bad.
Fix #759.
Co-authored-by: pcpthm <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/lib.rs')
0 files changed, 0 insertions, 0 deletions