Commit graph

462 commits

Author SHA1 Message Date
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