Commit graph

655 commits

Author SHA1 Message Date
bors[bot]
8f504dc873
Merge #11598
11598: feat: Parse destructuring assignment r=Veykril a=ChayimFriedman2

Part of #11532.

Lowering is not as easy and may not even be feasible right now as it requires generating identifiers: `(a, b) = (b, a)` is desugared into
```rust
{
    let (<gensym_a>, <gensym_b>) = (b, a);
    a = <gensym_a>;
    b = <gensym_b>;
}
```

rustc uses hygiene to implement that, but we don't support hygiene yet.

However, I think parsing was the main problem as lowering will just affect type inference, and while `{unknown}` is not nice it's much better than a syntax error.

I'm still looking for the best way to do lowering, though.

Fixes #11454.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2022-03-05 11:31:29 +00:00
hkalbasi
4fa8749c44 Preserve order of generic args 2022-03-04 11:46:14 +03:30
Chayim Refael Friedman
d9f0731bd2 Parse destructuring assignment
The only patterns we should parse are `..` in structs and `_`: the rest are either not supported or already valid expressions.
2022-03-02 01:51:25 +00:00
Chayim Refael Friedman
54fe3dc0f1 Fix if in #11561 2022-02-27 00:19:45 +00:00
Laurențiu Nicola
87c4a4104d Fix body selection in while loops 2022-02-26 16:45:06 +02:00
Chayim Refael Friedman
2df7a1af17 Generate AST code after rust-analyzer/ungrammar#46 2022-02-25 01:25:42 +00:00
Moritz Vetter
8848186213 fix(11422): have two different funuctions - one for iterating breaks, one for iteraating breaks and continues 2022-02-24 19:00:08 +01:00
Lukas Wirth
f13c98034b Make replace_derive_with_manual_impl work again 2022-02-22 10:20:44 +01:00
Chayim Refael Friedman
f70512cc17 Change single_let() and is_pattern_cond() to free functions 2022-02-21 08:34:36 +02:00
Chayim Refael Friedman
9881614db1 Upgrade ungrammar to 1.15.0 2022-02-21 08:34:36 +02:00
Chayim Refael Friedman
821b791b6d Validate let expressions
Emit an error if they're found in an invalid position.
2022-02-21 08:34:35 +02:00
Chayim Refael Friedman
a1b7169b48 Update tests
Unfortunately, we lost some recovery for expressions.
2022-02-21 08:34:35 +02:00
Chayim Refael Friedman
de8633f15f Parse let expressions in order to support let chains
We still need to reject freestanding `let` expressions: see https://github.com/rust-analyzer/rust-analyzer/issues/11320#issuecomment-1018212465.
2022-02-21 08:34:34 +02:00
Lukas Wirth
6940cca760 Move attribute path completions into attribute completion module 2022-02-03 15:50:14 +01:00
bors[bot]
34138379b5
Merge #11322
11322: Extract function also extracts comments r=Vannevelj a=Vannevelj

Fixes #9011

The difficulty I came across is that the original assist works from the concept of a `ast::StmtList`, a node, but that does not allow me to (easily) represent comments, which are tokens. To combat this, I do a whole bunch of roundtrips: from the `ast::StmtList` I retrieve the `NodeOrToken`s it encompasses. 

I then cast all `Node` ones back to a `Stmt` so I can apply indentation to it, after which it is again parsed as a `NodeOrToken`.

Lastly, I add a new `make::` api that accepts `NodeOrToken` rather than `StmtList` so we can write the comment tokens.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-02-01 23:05:28 +00:00
Lukas Wirth
45ff51ba22 Make more precise range macro upmapping 2022-01-31 15:53:44 +01:00
Lukas Wirth
cc04cfc982 Reduce allocations in attribute collection 2022-01-30 22:18:32 +01:00
Jeroen Vannevel
4ab7c4d99b removed prints 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
96ab4c6e6c hacky_block_expr_with_comments 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4896ffb65c removing unwraps 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4f3dd5bc08 very rough but comments get extracted 2022-01-22 12:08:32 +00:00
Lukas Wirth
91279db2b4 Move format specifier lexing from syntax to ide_db 2022-01-15 13:14:59 +01:00
Lukas Wirth
c3148cb396 Slightly cleanup HasFormatSpecifier::lex_format_specifier 2022-01-13 19:12:39 +01:00
Jonas Schievink
3dd5e273b6 Shrink diagnostic spans for errors inside macros 2022-01-08 15:40:42 +01:00
Jonas Schievink
67f548d8e9 Allow doc comments on all Items 2022-01-08 15:27:48 +01:00
bors[bot]
c17db9fa53
Merge #11107
11107: Fix generic type substitution in impl trait with assoc type r=pnevyk a=pnevyk

Fixes #11045 

The path transform now detects if a type parameter that is being substituted has an associated type. In that case it is necessary (or safe in general case) to fully qualify the substitution with a trait which the associated type belongs to.

This PR also fixes the previous wrong behavior of the substitution that could create an invalid tree `PATH_TYPE -> PATH_TYPE -> ...`.

Co-authored-by: Petr Nevyhoštěný <petr.nevyhosteny@gmail.com>
2022-01-08 09:05:09 +00:00
bors[bot]
41a0e95d61
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4 fix: Fix attribute stripping ignoring doc comments 2022-01-07 18:51:10 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Lukas Wirth
08adce61a1 Better interface for doc comment and attribute processing 2022-01-07 14:14:33 +01:00
Benjamin Coenen
b60a29ca94 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 14:13:34 +01:00
Lukas Wirth
69dbfc7754 Generate AnyHasDocComments node 2022-01-07 12:38:18 +01:00
Jonas Schievink
9dd42cd1e1 Useconst _ instead of mod __ 2022-01-06 12:55:33 +01:00
Jonas Schievink
3ff68f25b8 Expand attribute macros on impl and trait items 2022-01-06 12:30:16 +01:00
Benjamin Coenen
336c899a07 add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
Benjamin Coenen
0435463439 feat(diagnostics): use Default::default() expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-12-30 15:49:31 +01:00
Ariel Davis
d4262f4af8 Migrate to SyntaxNodePtr in new rowan 2021-12-29 23:48:53 -08:00
Aleksey Kladov
660cf34d8c dead code 2021-12-28 19:13:30 +03:00
Aleksey Kladov
bfc263f1f9 introduce hacks module 2021-12-28 18:57:13 +03:00
Aleksey Kladov
45bba40079 dead code 2021-12-28 17:00:55 +03:00
Aleksey Kladov
55f1564101 remove fragments from syntax 2021-12-28 17:00:55 +03:00
Aleksey Kladov
7e9c74d20b drop dead code 2021-12-28 17:00:55 +03:00
Aleksey Kladov
f0fefde401 remove Item::parse 2021-12-28 17:00:55 +03:00
Aleksey Kladov
b468bd6645 internal: start isolating ssr-related parsing APIs to SSR 2021-12-28 17:00:55 +03:00
Aleksey Kladov
b360ea91f2 internal: move inline parser tests to parser crate 2021-12-26 18:19:09 +03:00
Aleksey Kladov
0f74758fea internal: move outlined parser tests 2021-12-26 17:58:33 +03:00
Aleksey Kladov
f4cb0ff9be internal: move ws attachment logic to the parser crate
This has to re-introduce the `sink` pattern, because doing this purely
with iterators is awkward :( Maaaybe the event vector was a false start?

But, anyway, I like the current factoring more -- it sort-of obvious
that we do want to keep ws-attachment business in the parser, and that
we also don't want that to depend on the particular tree structure. I
think `shortcuts` module achieves that.
2021-12-26 16:47:10 +03:00
Aleksey Kladov
f692fafee8 rename 2021-12-25 22:03:57 +03:00
Aleksey Kladov
74de79b1da internal: rename 2021-12-25 22:02:26 +03:00
Aleksey Kladov
d0d05075ed internal: replace TreeSink with a data structure
The general theme of this is to make parser a better independent
library.

The specific thing we do here is replacing callback based TreeSink with
a data structure. That is, rather than calling user-provided tree
construction methods, the parser now spits out a very bare-bones tree,
effectively a log of a DFS traversal.

This makes the parser usable without any *specifc* tree sink, and allows
us to, eg, move tests into this crate.

Now, it's also true that this is a distinction without a difference, as
the old and the new interface are equivalent in expressiveness. Still,
this new thing seems somewhat simpler. But yeah, I admit I don't have a
suuper strong motivation here, just a hunch that this is better.
2021-12-25 22:02:26 +03:00
Petr Nevyhoštěný
d9b3242bcd Fix generic type substitution in impl trait with assoc type 2021-12-23 10:16:24 +01:00
Lukas Wirth
7f7a3644b3 Fully render type alias completions from hir 2021-12-21 16:36:23 +01:00
Lukas Wirth
40d5c58a80 Fully render const item completions from hir 2021-12-21 16:35:51 +01:00
bors[bot]
f46731a230
Merge #11028
11028: Bump MSRV (1.57) r=Veykril a=iDawer

This bumps MSRV on all crates to 1.57 except `la-arena`

#10986 requires >=1.57 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
Aleksey Kladov
a022ad68c9 internal: move all the lexing to the parser crate 2021-12-18 17:20:38 +03:00
Aleksey Kladov
799941e05e move tests 2021-12-18 14:55:20 +03:00
Aleksey Kladov
958f20ff84 minor: dead code 2021-12-18 14:55:20 +03:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
Lukas Wirth
901c7c7277 match_ast! takes a pattern to allow underscore usage 2021-12-14 12:44:31 +01:00
bors[bot]
791722b70a
Merge #10998
10998: Add number representation assists r=Veykril a=errx

Reimplemented assists from this PR https://github.com/rust-analyzer/rust-analyzer/pull/3683 with current APIs.
![image](https://user-images.githubusercontent.com/462486/145726792-47700215-26f2-4fdc-9520-63d1487901e5.png)
![image](https://user-images.githubusercontent.com/462486/145726802-f528a2f7-9159-41d3-b459-fc3fae033e60.png)


I've decided not to add options about size of the groups so behaviour is similar to clippy's. 
Minimal number length is also taken from clippy.


Co-authored-by: Oleg Matrokhin <matrokhin@gmail.com>
2021-12-13 18:49:06 +00:00
Oleg Matrokhin
60605a24d4 Reuse results from split_into_parts() 2021-12-13 21:16:04 +03:00
Oleg Matrokhin
8b03b41b7a Add number representation assists 2021-12-13 19:35:38 +03:00
Aleksey Kladov
57e6ef0bfb tighten up invariants 2021-12-12 19:22:37 +03:00
Aleksey Kladov
965585748e more orthogonal interface 2021-12-12 18:38:49 +03:00
Aleksey Kladov
6ce587ba5a parser tests work 2021-12-12 18:31:05 +03:00
Laurențiu Nicola
8782e8e704 Bump deps 2021-12-12 13:10:21 +02:00
Lukas Wirth
0c98a01b3e Remove possible multiline details in completions 2021-11-24 16:08:11 +01:00
iDawer
601413df8f Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
zhoufan
a539b5e693 fix: parse the range pat inside the tuple pat 2021-11-18 11:11:37 +08:00
Laurențiu Nicola
b23bebebc0 Remove validation of super in use paths 2021-11-16 20:02:42 +02:00
bors[bot]
6c7be6cd84
Merge #10734
10734: fix: add generic parameters in convert to manual impl assist r=Veykril a=TheDoctor314

Fixes #10041.

Co-authored-by: TheDoctor314 <64731940+TheDoctor314@users.noreply.github.com>
2021-11-16 11:27:11 +00:00
Lukas Wirth
92f7db447c minor: Lift out FxIndex{Map/Set} types into ide_db 2021-11-16 12:15:47 +01:00
TheDoctor314
58a24de7d8 Fix impl_def_from_trait
Revert "Fix `impl_trait` function to emit correct ast"

This reverts commit 55a4813151.

Fix `impl_def_from_trait`

It now generates the correct `ast::Impl` using
`generate_trait_impl_text` and parses it to form the right node (copied
from the private fn 'make::ast_from_text').
2021-11-15 22:28:22 +05:30
TheDoctor314
55a4813151 Fix impl_trait function to emit correct ast
`impl_trait` code copied from `generate_impl_text_inner` to properly
handle the bounds for the generic parameters.
2021-11-11 14:16:59 +05:30
bors[bot]
1e8d1e84b2
Merge #10689
10689: Handle pub tuple fields in tuple structs r=Veykril a=adamrk

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.

I guess this is a really minor case because there's not much reason
for having a tuple type within a struct tuple, but it is valid rust syntax...

Co-authored-by: Adam Bratschi-Kaye <ark.email@gmail.com>
2021-11-10 21:08:51 +00: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
TheDoctor314
05b368f065 Add generic parameters for manual impl assist
The `impl_trait` function takes an optional `GenericParamList` to create
the trait impl.
2021-11-10 12:53:48 +05:30
Lukas Wirth
2f5afba9f8 Replace some String usages with SmolStr in completions 2021-11-05 12:30:39 +01:00
Lukas Wirth
c93983e76f Fix for-loop expressions breaking with BlockExpr iterable 2021-10-30 16:37:32 +02:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02: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
bors[bot]
a75353e8ac
Merge #9939
9939: feat: Adding extract_module assist r=Veykril a=feniljain

Should solve https://github.com/rust-analyzer/rust-analyzer/issues/9591

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-22 09:29:16 +00: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
vi_mi
32b95ea310 feat: Adding extract_module assist 2021-10-16 13:36:06 +03:00
bors[bot]
bfb8f73fb3
Merge #10545
10545: A few clippy fixes r=Veykril a=Milo123459

A few clippy fixes

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2021-10-14 20:10:59 +00:00
bors[bot]
0af9d1fc8a
Merge #10546
10546: feat: Implement promote_local_to_const assist r=Veykril a=Veykril

Fixes #7692, that is now one can invoke the `extract_variable` assist on something and then follow that up with this assist to turn it into a const.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-14 19:51:34 +00:00
Lukas Wirth
06286ee90b Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
Milo
35de195c41 a few clippy fixes 2021-10-14 19:57:21 +01:00
Yoshua Wuyts
680dd9d952 Enable delegation generation for complex types 2021-10-14 13:23:46 +02:00
Ryan Levick
0ff89deb69 Add basic support for delegation 2021-10-13 18:05:09 +02:00
Lukas Wirth
03fcf1b246 Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
bors[bot]
4439cd8c68
Merge #10506
10506: Add comment r=lnicola a=k-nasa

## Why


This code looks logic-bug ...


ce86534e1c/crates/syntax/src/syntax_node.rs (L50)


However, this code has been intentionally disabled.
It's a good idea to write a comment

ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357

## What

- I added comment

Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:56:47 +00:00
k-nasa
84bc6e159a Add comment 2021-10-10 16:53:37 +09:00
bors[bot]
64ca0f63bf
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa

## Why

Delete clones for efficiency

## What

- I erased unnecessary clones


Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:17:52 +00:00
k-nasa
9dd823a0e1 remove comment 2021-10-10 13:16:34 +09:00
k-nasa
3829cd981a Revert "update comment"
This reverts commit 820393f72d.
2021-10-10 10:51:45 +09:00
k-nasa
b50cb5c261 Remove neesless clone 2021-10-10 10:50:51 +09:00
k-nasa
820393f72d update comment 2021-10-10 10:16:32 +09:00
k-nasa
42377d3dad Add code comment 2021-10-10 10:10:52 +09:00
Aleksey Kladov
c2e425dd00 internal: make sure macro test expand to valid syntax 2021-10-09 18:06:24 +03:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03: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
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11: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
bors[bot]
ebe6c38a44
Merge #10438
10438: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 11:06:06 +00:00
Lukas Wirth
0943c4be8b minor: Simplify 2021-10-03 13:05:42 +02:00
vi_mi
61643513b6 fix: await insertion with try_expr during extract_function 2021-10-03 09:41:21 +00:00
zhoufan
116c7aef7f move outer_attrs call before the match 2021-10-03 09:22:02 +08:00
Aleksey Kladov
7dbf24fc7a minor: dead code 2021-10-02 15:42:10 +03:00
Aleksey Kladov
d5c5b7cd12 internal: remove deprecated method 2021-10-02 15:28:55 +03:00
Aleksey Kladov
f04f8ddb0d minor: regen 2021-10-02 15:20:16 +03:00
Aleksey Kladov
f3a1ff786f minor: generated code readability 2021-10-02 15:20:03 +03:00
zhoufan
0ee6b70b34 Parse outer attributes on StructPatternEtCetera 2021-10-02 09:57:44 +08:00
Lukas Wirth
774a8cf08b Fix inline_call breaking RecordExprField shorthands 2021-09-28 19:22:32 +02:00
Lukas Wirth
b6ed91a6de Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
Lukas Wirth
a28c5d7311 Rename Dyn* nodes to Any* nodes 2021-09-27 12:45:36 +02: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
bors[bot]
c51a3c78cf
Merge #10358
10358: internal: Remove inherent methods from ast nodes that do non-syntactic complex tasks  r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-26 14:49:25 +00:00
Lukas Wirth
151afdfe5c Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
Aleksey Kladov
defe805fb7 internal: fix and force-disable block validation ;-(
Originally we tried to maintain the invariant that `{}` always match.
That is, that in the parse tree the pair of corresponding `{}` is always
first and last tokens of some nodes.

We had the code to validate that, but apparently it's been broken for
**years** since we introduced tokens/nodes split. Fixing it now makes
some tests fail.

It's unclear if we want to keep this invariant: there's a strong
motivation for breaking it in the following case:

```
use std::{ // unclosed paren

fn main() {

}

} // don't actually want to pair up this with the one from `use`
```

So let's fix the code, but disable it for the time being
2021-09-26 15:49:23 +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
bors[bot]
0cb9ee2054
Merge #10346
10346: minor: align code with code-style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-25 11:56:23 +00:00
Aleksey Kladov
5767f31cbf minor: align code with code-style 2021-09-25 14:55:42 +03:00
Aleksey Kladov
929fca5adc minore: improve consistency 2021-09-25 14:36:46 +03:00
Aleksey Kladov
f27cda6865 minor: more condensed tests 2021-09-25 14:24:57 +03:00
Aleksey Kladov
1567bbb73e minor: more focusted tests 2021-09-25 14:04:27 +03:00
Lukas Wirth
42eb4efb5b Cleanup 2021-09-23 16:28:03 +02:00
Lukas Wirth
83e97adfff Simplify 2021-09-21 16:15:30 +02:00
Lukas Wirth
b36f12dba5 Simplify 2021-09-21 16:05:21 +02:00
Lukas Wirth
6d6e0b8f21 Generate ast nodes for each ast trait 2021-09-21 15:52:11 +02:00
bors[bot]
b7bedf16a1
Merge #10289
10289: fix: Only strip derive attributes when preparing macro input r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10246
cc https://github.com/rust-analyzer/rowan/pull/114, follow up to https://github.com/rust-analyzer/rust-analyzer/pull/10025

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-19 21:46:51 +00:00
Lukas Wirth
a6dde501df Only strip derive attributes when preparing macro input 2021-09-19 23:38:38 +02:00
Lukas Wirth
9c39363ada Simplify 2021-09-19 23:34:07 +02:00
Lukas Wirth
3987bf5d6f Simplify 2021-09-19 19:00:06 +02:00
Aleksey Kladov
a6181bfdb7 internal: more focused tests for const arguments 2021-09-19 16:35:10 +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
8ae1f9c335 internal: add erroneous test for double turbo fish
We parse `f` successfully, but that is a bug.
2021-09-19 11:42:10 +03:00
Aleksey Kladov
c0556bd8c1 minor: improve readability 2021-09-18 15:56:26 +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