Commit Graph

240 Commits

Author SHA1 Message Date
Aleksey Kladov addfd8d9e8 start SOA parser interface 2021-12-12 16:54:09 +03:00
Laurențiu Nicola f5db6e0e95 Bump parser step limit a little 2021-12-06 11:47:36 +02:00
zhoufan a539b5e693 fix: parse the range pat inside the tuple pat 2021-11-18 11:11:37 +08:00
Adam Bratschi-Kaye 0d54754ca7 Handle pub tuple fields in tuple structs
The current implementation will throw a parser error for tuple structs
that contain a pub tuple field. For example,
```rust
struct Foo(pub (u32, u32));
```
is valid Rust, but rust-analyzer will throw a parser error.  This is
because the parens after `pub` is treated as a visibility context.
Allowing a tuple type to follow `pub` in the special case when we are
defining fields in a tuple struct can fix the issue.
2021-11-10 21:29:50 +01:00
Aleksey Kladov 485c5e6717 internal: remove unused dollars 2021-10-23 20:44:35 +03:00
Laurențiu Nicola 8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
Lukas Wirth 1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00
Lukas Wirth b219a4c465 internal: Parse const trait bounds 2021-10-19 14:20:00 +02:00
Jonas Schievink f8acae7895 Support let...else 2021-10-07 17:06:24 +02:00
cynecx 07cd19dcef parser: fix parsing of macro call inside generic args 2021-10-06 22:41:35 +02:00
bors[bot] 94fa49c0a3 Merge #10420
10420: Parse outer attributes on StructPatternEtCetera r=jonas-schievink a=XFFXFF

Try to fix https://github.com/rust-analyzer/rust-analyzer/issues/8610  
Related pr in ungrammer: https://github.com/rust-analyzer/ungrammar/pull/41

Co-authored-by: zhoufan <1247714429@qq.com>
2021-10-06 15:05:40 +00:00
bors[bot] 86c534f244 Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
zhoufan a248f39cb4 make Some(1..) parsed 2021-10-04 17:33:48 +08:00
Aramis Razzaghipour eff195852d Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
Aramis Razzaghipour 55c0b86cde Add semicolons for consistency
`clippy::semicolon_if_nothing_returned`
2021-10-03 23:39:43 +11:00
zhoufan 116c7aef7f move outer_attrs call before the match 2021-10-03 09:22:02 +08:00
Aleksey Kladov 393f80e036 minor 2021-10-02 13:20:45 +03:00
zhoufan 0ee6b70b34 Parse outer attributes on StructPatternEtCetera 2021-10-02 09:57:44 +08:00
Aleksey Kladov 2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00
Aleksey Kladov 56964c9bd3 feat: allow attributes on all expressions
Attrs are syntactically valid on any expression, even if they are not
allowed semantically everywhere yet.
2021-09-25 22:19:27 +03:00
Aleksey Kladov 7dc331faef fix: correct extend_to logic in parser
Previously we swapped to events in the buffer, but that might be wrong
if there aer `forward_parent` links pointing to the swapped-out node.

Let's do the same via parent links instead, keeping the nodes in place
2021-09-25 22:09:50 +03:00
Aleksey Kladov 6997adfee7 simplify attribute parsing 2021-09-25 18:07:51 +03:00
Aleksey Kladov f27cda6865 minor: more condensed tests 2021-09-25 14:24:57 +03:00
Aleksey Kladov f692be853b minor: link my own pratt parsing article :-) 2021-09-25 14:20:34 +03:00
Aleksey Kladov 1567bbb73e minor: more focusted tests 2021-09-25 14:04:27 +03:00
Aleksey Kladov a6f17f7436 minor: more readable code 2021-09-25 13:27:53 +03:00
Aleksey Kladov a6181bfdb7 internal: more focused tests for const arguments 2021-09-19 16:35:10 +03:00
Aleksey Kladov 09531b703d minor: simplify 2021-09-19 14:50:53 +03:00
Aleksey Kladov 0005678649 minor: simplify 2021-09-19 14:26:35 +03:00
Aleksey Kladov f99bdf4cc0 fix: don't allow two turbo-fishes in generic arguments 2021-09-19 12:09:50 +03:00
Aleksey Kladov 8009ccc27d minor: improve readability 2021-09-19 11:34:25 +03:00
Aleksey Kladov 25adc5e9f0 minor: reduce duplication 2021-09-19 11:19:31 +03:00
Aleksey Kladov fbb6a6a95b fix: correctly handle jointness 2021-09-18 16:09:12 +03:00
Aleksey Kladov c0556bd8c1 minor: improve readability 2021-09-18 15:56:26 +03:00
Aleksey Kladov ed84717869 internal: better naming 2021-09-18 15:55:07 +03:00
Aleksey Kladov 3dc2aeea0f internal: parser cleanup 2021-09-18 15:46:28 +03:00
Aleksey Kladov af9fd37cd9 internal: minimize use_tree parser tests
The code here is intentionally dense and does exactly what is written.
Explaining semantic difference between Rust 2015 and 2018 doesn't help
with understanding syntax. Better to just add more targeted tests.
2021-09-18 15:22:49 +03:00
Aleksey Kladov 1d2e9818d6 internal: parser cleanups 2021-09-18 14:53:46 +03:00
Aleksey Kladov aaadaa40bd internal: more focused trait item parsing tests 2021-09-18 14:34:29 +03:00
Aleksey Kladov 3474e3b3b1 intenral: more local tests for statics 2021-09-18 01:02:43 +03:00
Aleksey Kladov 1feb8e89d5 minor: cleanup const parsing 2021-09-18 00:58:35 +03:00
Aleksey Kladov 46326b8db7 minor: better test placement 2021-09-18 00:54:03 +03:00
Aleksey Kladov 2195ecd7e7 internal: cleanup adt parsing 2021-09-18 00:50:27 +03:00
Aleksey Kladov d890c767c4 internal: cleanup item parsing 2021-09-18 00:33:42 +03:00
Aleksey Kladov ec2043a082 minor: parser cleanup 2021-09-18 00:14:20 +03:00
Aleksey Kladov 4d2956e775 minor: simplify 2021-09-17 23:31:37 +03:00
Aleksey Kladov 366d3d7544 minor: cleanup 2021-09-17 23:27:26 +03:00
Aleksey Kladov 329b01ca67 minor: simplify 2021-09-17 22:26:39 +03:00
Aleksey Kladov 77e8421d0f internal: more local parsing tests for macros 2021-09-17 22:21:57 +03:00
Aleksey Kladov 073d5f7733 internal: more focused parsing tests 2021-09-17 22:15:12 +03:00