Commit graph

13082 commits

Author SHA1 Message Date
Lukas Wirth
774a8cf08b Fix inline_call breaking RecordExprField shorthands 2021-09-28 19:22:32 +02:00
bors[bot]
533ca584c3
Merge #10378
10378: fix: Implement most proc_macro span handling methods r=jonas-schievink a=jonas-schievink

This closes https://github.com/rust-analyzer/rust-analyzer/issues/10368 – some APIs are still missing, but they are either for unstable features or require https://github.com/rust-analyzer/rust-analyzer/issues/9403

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-27 18:00:08 +00:00
Jonas Schievink
577aedb8cf Implement most proc_macro span handling methods 2021-09-27 19:58:07 +02:00
bors[bot]
afa9e31b80
Merge #10377
10377: fix: fix proc macro crash on nightly r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10235

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-27 17:43:32 +00:00
Jonas Schievink
9641bc7369 Implement save_span / recover_proc_macro_span 2021-09-27 19:42:39 +02:00
bors[bot]
bcf04b19f8
Merge #10375
10375: minor: Use SmallVec<[_; 1]> in `descend_into_macros_impl` r=Veykril a=Veykril

A lot of descends don't actually descend in which case we don't wanna allocate
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-27 17:19:55 +00:00
Lukas Wirth
dedc2368b9 Use SmallVec<[_; 1]> in descend_into_macros_impl 2021-09-27 19:18:26 +02:00
Jonas Schievink
d05eae6ada Make stringify! prettify its input
This will insert whitespace if the invocation is inside another macro
2021-09-27 19:02:03 +02:00
bors[bot]
f22eea9053
Merge #10372
10372: minor: Cleanup descend_into_macros_impl r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-27 16:45:40 +00:00
Lukas Wirth
75660ff94f Cleanup descend_into_macros_impl 2021-09-27 18:44:40 +02:00
bors[bot]
ffcaceb80f
Merge #10366
10366: feat: Enable attribute proc macros by default r=lnicola a=lnicola

Closes #9868

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-27 15:12:44 +00:00
Laurențiu Nicola
81891f7abe Enable attribute proc macros by default 2021-09-27 18:11:31 +03:00
Giacomo Stevanato
72bb49467d Remove SourceMap 2021-09-27 15:23:50 +02:00
Giacomo Stevanato
fe2b1615de Remove GenericParams::new 2021-09-27 15:20:40 +02:00
Giacomo Stevanato
6e4bf22724 Make impls of HasChildSource and ChildBySource for GenericDefId not use GenericParams::new 2021-09-27 15:20:40 +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
bors[bot]
cd7b26c6eb
Merge #10352
10352: feat: Implement inline callers assist r=Veykril a=Veykril

Fixes #7242

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-26 14:02:25 +00:00
Lukas Wirth
215a077ee4 Remove imports when inlining all calls in a file 2021-09-26 16:01:54 +02:00
Lukas Wirth
79c70d0ad3 Simplify 2021-09-26 14:56:43 +02:00
Lukas Wirth
1a50f904ef Reject recursive calls in inline_call 2021-09-26 14:55: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
bors[bot]
0618100855
Merge #10354
10354: internal: overhaul expression attribute parsing r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-26 08:23:29 +00: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
Lukas Wirth
1ccb21a0ca feat: Implement inline callers assist 2021-09-25 18:39:43 +02:00
bors[bot]
d401f2a062
Merge #10211
10211: assists: Promote module to folder r=jonas-schievink a=longfangsong

Close part of #10143.

This PR adds a assist to promote module to directory, which means make a .rs file module into a directory style module with the same name.

![未命名(1)](https://user-images.githubusercontent.com/13777628/132958377-14555d6f-a64a-4b9b-9154-90a3b86fd685.gif)


Co-authored-by: longfangsong <longfangsong@icloud.com>
2021-09-25 15:32:00 +00:00
Aleksey Kladov
6997adfee7 simplify attribute parsing 2021-09-25 18:07:51 +03:00
longfangsong
22abbe86f3 Address comments 2021-09-25 22:48:57 +08: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
f692be853b minor: link my own pratt parsing article :-) 2021-09-25 14:20:34 +03:00
Aleksey Kladov
d72f7cf3af internal: add => () rule; emphasize n_items rule 2021-09-25 14:10:25 +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
Jonas Schievink
7860d6ade6 Fix item-level lazy macro errors 2021-09-24 21:17:25 +02:00
Jonas Schievink
5967f3d3a9 Fix diagnostics in unnamed consts 2021-09-24 20:41:24 +02:00
bors[bot]
8b08666343
Merge #10334
10334: Give rustfmt spawn error context. r=jonas-schievink a=aDotInTheVoid

This mean if you misconfigure to

```json
{
    "rust-analyzer.rustfmt.overrideCommand": [
        "./nonono"
    ]
}
```

The error message is

```
[Error - 17:54:33] Request textDocument/formatting failed.
  Message: Failed to spawn "./nonono"
  Code: -32603 
```

instead of

```
[Error - 17:56:12] Request textDocument/formatting failed.
  Message: No such file or directory (os error 2)
  Code: -32603 
```

I'm not sure how to test this, or if it needs a test.

Co-authored-by: Nixon Enraght-Moony <nixon.emoony@gmail.com>
2021-09-24 17:07:18 +00:00
Jonas Schievink
b8eb63f2b2 Avoid some Arc cloning 2021-09-24 18:57:08 +02:00
Nixon Enraght-Moony
720a3da4ac Give rustfmt spawn error context. 2021-09-24 17:51:47 +01:00
bors[bot]
eb17e90eba
Merge #10105
10105: RfC: Use `todo!()` instead of `()` for missing fields r=jonas-schievink a=jo-so

Most commonly a field of a struct can be initialized with its default value than an empty tuple.

Co-authored-by: Jörg Sommer <joerg@jo-so.de>
2021-09-24 15:12:17 +00:00
bors[bot]
377476ac45
Merge #10332
10332: minor: Allow overwriting RUST_BACKTRACE for the server manually r=jonas-schievink a=Veykril

Trying to figure out why we aren't getting backtraces for windows builds from CI, this let's one set the backtraces to `FULL`
Might be cc https://github.com/rust-lang/rust/issues/87481
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-24 14:59:02 +00:00
bors[bot]
2117ba0235
Merge #10331
10331: minor: Include macro path in eager macro resolve error r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-24 14:51:19 +00:00
Lukas Wirth
983e19c868 Allow setting RUST_BACKTRACE for the server manually 2021-09-24 15:38:00 +02:00
Jonas Schievink
af3d6a4b61 Include macro path in eager macro resolve error 2021-09-24 15:34:57 +02:00