Commit graph

223 commits

Author SHA1 Message Date
Aleksey Kladov
5e5eb6a108 Align grammar for record patterns and literals
The grammar now looks like this

   [name_ref :] pat
2020-04-12 00:00:15 +02:00
Aleksey Kladov
6b49e774e2 Remove dead code 2020-04-11 23:08:05 +02:00
Aleksey Kladov
7a39bc3ba2 Make records grammar more orthogonal
We used

  name [: expr]

grammar before, now it is

  [name :] expr

which makes things simpler
2020-04-11 19:20:41 +02:00
Aleksey Kladov
5c5bde47fb Rename some tokens 2020-04-10 17:07:09 +02:00
Aleksey Kladov
8d71a6bf0c Scale token generation back 2020-04-10 16:10:28 +02:00
Luca Barbieri
74e3b48806 Parse correctly fn f<T>() where T: Fn() -> u8 + Send {}
We used to parse it as T: Fn() -> (u8 + Send), which is different from
the rustc behavior of T: (Fn() -> u8) + Send
2020-04-09 13:05:41 +02:00
Luca Barbieri
60f4d7bd8c Provide more complete AST accessors to support usage in rustc 2020-04-09 11:50:37 +02:00
Edwin Cheng
53d05448c1 Add L_DOLLAR for TYPE_RECOVERY_SET 2020-04-08 18:34:20 +08:00
Aleksey Kladov
da8eb29a2f Macro patterns are not confused with expressions.
We treat macro calls as expressions (there's appropriate Into impl),
which causes problem if there's expresison and non-expression macro in
the same node (like in the match arm).

We fix this problem by nesting macor patterns into another node (the
same way we nest path into PathExpr or PathPat). Ideally, we probably
should add a similar nesting for macro expressions, but that needs
some careful thinking about macros in blocks: `{ am_i_expression!() }`.
2020-04-03 16:12:38 +02:00
Aleksey Kladov
0e46ed8420 Cleanups 2020-04-03 15:44:06 +02:00
Aleksey Kladov
f6188caaa0 Fix parsing lambdas with return type
We should eat only a single block, and not whatever larger expression
may start with a block.

closes #3721
2020-03-25 17:01:28 +01:00
Aleksey Kladov
89694ec8f6 Support arbitrary discriminants
Closes #3661
2020-03-20 08:50:34 +01:00
Florian Diebold
e6ec4a329f Better fix for stuck parser? 2020-03-16 18:38:19 +01:00
Florian Diebold
c32529ddd0 Get tests working 2020-03-16 18:38:19 +01:00
Aleksey Kladov
bee5cdb359 Parse variadics correctly
closes #3571
2020-03-13 13:54:14 +01:00
Aleksey Kladov
1e19847af3 Move verbose tests out of line 2020-03-13 12:20:42 +01:00
Aleksey Kladov
4a745cc8cf Fix parsing of stement-ish binary expressions
closes #3512
2020-03-11 14:28:18 +01:00
Edwin Cheng
1465cc0c4f Implement concat macro 2020-03-04 01:21:14 +08:00
Aleksey Kladov
a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Edwin Cheng
f4e48ad3e4 Parse attr in rhs of let stmts 2020-02-28 13:08:47 +08:00
Veetaha
59dc797eb3
Fix dat comment 2020-02-22 14:16:13 +02:00
Kirill Bulatov
eceaf94f19 More manual clippy fixes 2020-02-18 16:12:37 +02:00
Kirill Bulatov
b8ddcb0652 Run cargo +nightly fix --clippy -Z unstable-options 2020-02-18 16:03:08 +02:00
Han Mertens
b435fe8b77 Add test for unnamed argument in function pointer 2020-02-12 22:55:37 +01:00
Han Mertens
0e10e77a78 Support unnamed arguments in function pointers
Fixes #3089
2020-02-12 21:40:05 +01:00
Matthew Jasper
49b53cd7a0 Address review comments 2020-02-10 20:11:44 +00:00
Matthew Jasper
8c8d0bb34f Add or- and parenthesized-patterns 2020-02-09 22:06:15 +00:00
Kirill Bulatov
740a26b7d2 Rename add import assist 2020-02-07 23:53:08 +02:00
bors[bot]
8337dcd9e2
Merge #3047
3047: Update async unsafe fn ordering in parser r=matklad a=kiljacken

As of rust-lang/rust#61319 the correct order for functions that are both unsafe and async is: `async unsafe fn` and not `unsafe async fn`.

This commit updates the parser tests to reflect this, and corrects parsing behavior to accept the correct ordering.

Fixes #3025

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-02-07 13:21:02 +00:00
Emil Lauridsen
73ec2ab184 Update async unsafe fn ordering.
As of rust-lang/rust#61319 the correct order for functions that are both
unsafe and async is: `async unsafe fn` and not `unsafe async fn`.

This commit updates the parser tests to reflect this, and corrects
parsing behavior to accept the correct ordering.

Fixes #3025
2020-02-07 13:51:51 +01:00
Toby Dimmick
90ff2be4e8 PR tweaks 2020-02-07 12:36:33 +00:00
Toby Dimmick
0183952d2e Closure params test 2020-02-06 20:39:27 +00:00
Toby Dimmick
e1921ea59c rustfmt 2020-02-06 20:04:35 +00:00
Toby Dimmick
7e66785859 Rework value parameter parsing
- `Fn__(...)` parameters with idents/patterns no longer parse
- Trait function parameters with arbitrary patterns parse
- Trait function parameters without idents/patterns no longer parse
- `fn(...)` parameters no longer parse with patterns other than a single ident
2020-02-06 19:45:51 +00:00
Veetaha
3ec781d4f2 ra_syntax: remove code duplication and token reevaluation from ast::Literal::kind() 2020-01-22 13:02:21 +02:00
Aleksey Kladov
3a859e587f Nest attrs into exprs in function args 2020-01-17 11:47:07 +01:00
Aleksey Kladov
b7c45fba57 Extract expr_with_attrs 2020-01-17 11:44:40 +01:00
Aleksey Kladov
90b8a31b83
Merge pull request #2813 from jyn514/arg_attributes
Allow attributes before function arguments
2020-01-17 11:15:07 +01:00
Joshua Nelson
f077d5c303
move inline function closer to relevant code
also updates generated inline tests
2020-01-16 22:20:17 -05:00
bors[bot]
ea2b27d8b9
Merge #2865
2865: fix(mixed): fixed a couple of typos and added a todo r=kjeremy a=Veetaha

Fixed a couple of typos and added a todo while studying the codebase.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-17 02:20:16 +00:00
Aleksey Kladov
5398b9eeba Minimize test 2020-01-16 18:39:29 +01:00
Aleksey Kladov
ab0a11b1de Simplify array parsing 2020-01-16 18:35:03 +01:00
Edwin Cheng
a766883a75 fix formating 2020-01-16 23:48:03 +08:00
Edwin Cheng
ed8d5c86e3 Fix array element attribute position 2020-01-16 23:37:43 +08:00
Joshua Nelson
c78e34968f
shrink inline tes 2020-01-15 19:12:56 -05:00
Veetaha
a24dcd7bab fix(ra_parser.typo): amend 'format language' to 'formal language' 2020-01-15 23:29:55 +02:00
Joshua Nelson
c3ac2c93fb
Allow attributes before function arguments
This adds support for function calls of the form:

```rust
  (
    #[attr(...)] 1.2,
    #[attr_one(...)]
    #[attr_two(...)]
    1.5,
    ... etc ...
  )
```

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2801
2020-01-12 10:25:41 -05:00
Emil Lauridsen
aa433c67d8 Parse trait aliases 2020-01-09 18:40:01 +01:00
Michael Chesser
ce1b34fd59 Improve const generics parsing
- Handle const generics type args
- Fix issue with const generic as first parameter in trait impl
2020-01-07 09:29:03 +10:30
Aleksey Kladov
084bd304f3 Switch ast declaration from ron to a macro 2020-01-03 21:54:10 +01:00