Commit Graph

43 Commits

Author SHA1 Message Date
Aleksey Kladov 3a859e587f Nest attrs into exprs in function args 2020-01-17 11:47:07 +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
Aleksey Kladov 5398b9eeba Minimize test 2020-01-16 18:39:29 +01:00
Edwin Cheng ed8d5c86e3 Fix array element attribute position 2020-01-16 23:37:43 +08: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
bors[bot] 436df298ba Merge #2642
2642: Use name instead of ident in parser for macro 2.0 syntax r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-22 08:05:02 +00:00
bors[bot] d33493d779 Merge #2641
2641: Parse const generics r=matklad a=roblabla

Adds very primitive support for parsing const generics (`const IDENT: TY`) so that rust-analyzer stops complaining about the syntax being invalid.

Fixes #1574
Fixes #2281 

Co-authored-by: roblabla <unfiltered@roblab.la>
2019-12-22 07:56:33 +00:00
Edwin Cheng 737045c1ea Use name instead of ident for macro 2.0 sytnax 2019-12-22 11:11:10 +08:00
roblabla b04d4a88d1 Parse const generics
Fixes #1574
Fixes #2281
2019-12-22 01:32:08 +00:00
Edwin Cheng bea8f58118 Add macro 2.0 support in parser 2019-12-21 18:29:14 +08:00
Edwin Cheng 4a7e19946a Fix parser for macro call in pattern position 2019-12-20 23:26:04 +08:00
Aleksey Kladov e1c0bdaf75 Introduce dedicated AST node for union
Although structs and unions have the same syntax and differ only in
the keyword, re-using the single syntax node for both of them leads to
confusion in practice, and propagates further down the hir in an
upleasent way.

Moreover, static and consts also share syntax, but we use different
nodes for them.
2019-11-25 17:50:49 +03:00
bors[bot] d9338dfa98 Merge #1951
1951: Lower the precedence of the `as` operator. r=matklad a=goffrie

Previously, the `as` operator was being parsed like a postfix expression, and
therefore being given the highest possible precedence. That caused it to bind
more tightly than prefix operators, which it should not. Instead, parse it
somewhat like a normal binary expression with some special-casing.

Fixes #1851.

Co-authored-by: Geoffry Song <goffrie@gmail.com>
2019-10-08 08:44:26 +00:00
Geoffry Song b4fe06bc17 Move tests around 2019-10-05 16:33:05 -07:00
Geoffry Song 9638adaa40 Fix parsing of block expressions in "forbid_structs" contexts.
Forbidding block expressions entirely is too strict; instead, we should only
forbid them in contexts where we are parsing an optional RHS (i.e. the RHS of a
range expression).
2019-10-03 00:39:52 -07:00
Geoffry Song b63f260bbc Lower the precedence of the as operator.
Previously, the `as` operator was being parsed like a postfix expression, and
therefore being given the highest possible precedence. That caused it to bind
more tightly than prefix operators, which it should not. Instead, parse it
somewhat like a normal binary expression with some special-casing.
2019-10-03 00:27:09 -07:00
uHOOCCOOHu 71efdaa636 Parse correct AttrInput 2019-09-30 16:11:40 +08:00
kjeremy 5a65d4d9fb Add indexing to record_field_pat 2019-09-20 11:43:34 -04:00
Dylan MacKenzie 0956323bb7 Generate dot_dot_test 2019-09-14 17:08:22 -07:00
Dylan MacKenzie da3815122d Bless old tests containing a .. pattern 2019-09-14 17:08:22 -07:00
Aleksey Kladov 470fc4765c update test data 2019-09-02 20:15:51 +03:00
Dylan MacKenzie c93903e9c7 Generate and bless tests 2019-08-23 16:24:30 -07:00
Aleksey Kladov 5b18a4eef9 rename struct -> record, pos -> tuple 2019-08-23 16:59:50 +03:00
Dylan MacKenzie 3e14b16c4d Add test for nested box pattern 2019-08-22 12:53:54 -07:00
bors[bot] 5ed6a13a2c Merge #1685
1685: fix error of RangeFrom in for-loop r=DJMcNab a=bravomikekilo

fix [issue-1542](https://github.com/rust-analyzer/rust-analyzer/issues/1542) @matklad 

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-08-15 05:49:13 +00:00
bors[bot] 19e0d7d596 Merge #1676
1676: Fix for<'lifetime> for types specified by path r=matklad a=eupn

Fixes #1467.

Co-authored-by: Evgenii P <eupn@protonmail.com>
2019-08-14 15:10:31 +00:00
bravomikekilo 4f31fed362 fix test position 2019-08-14 21:20:04 +08:00
bravomikekilo 3fce56280f fix test 2019-08-14 12:42:58 +08:00
bravomikekilo 2bebdf0b37 fix error of RangeFrom in for-loop 2019-08-14 11:55:21 +08:00
bors[bot] 978e3e384b Merge #1636
1636: fix block parse problem r=matklad a=bravomikekilo

try to fix [issue-1598](https://github.com/rust-analyzer/rust-analyzer/issues/1598).

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-08-13 12:46:47 +00:00
bravomikekilo eb0e9bd981 add inline test 2019-08-13 18:17:10 +08:00
Evgenii P f1e62501c3 Fix for<'lifetime> for types specified by path 2019-08-11 16:56:05 +07:00
Aleksey Kladov f3ee5a1509 Move numeric names inside of NameRef 2019-08-09 12:16:47 +02:00
Evgenii P 957b5ed23a Parse tuple struct field initialization 2019-08-09 15:38:52 +07:00
bors[bot] 87608904f6 Merge #1661
1661: Parse function parameters attributes r=matklad a=eupn

Fixes #1397. The [RFC-2565](https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md) specifies `#[attributes]` to function parameters:

```rust
fn foo(#[attr] a, #[unused] b, #[must_use] ...) {
    // ...
}
```

This PR adds those attributes into grammar and to the parser, extending corresponding inline tests.

Co-authored-by: Evgenii P <eupn@protonmail.com>
2019-08-08 13:04:28 +00:00
Evgenii P 6fa2d82147 Fix parser tests according to review 2019-08-08 09:12:07 +07:00
Aleksey Kladov d6ab1af086 assoc types bounds 2019-08-07 21:00:02 +02:00
Evgenii P 9ea36703d2 Fix variadic arg inline test 2019-08-07 23:48:21 +07:00
Evgenii P 3fb58c620c Add function parameters attributes 2019-08-07 23:42:28 +07:00
Aleksey Kladov 459241f272 move syntax tests to unit tests 2019-07-24 12:49:19 +03:00