Commit Graph

17090 Commits

Author SHA1 Message Date
bors[bot]
da80dfc022
Merge #8398
8398: Fix inference with conditionally compiled tails r=flodiebold a=DJMcNab

Fixes #8378

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2021-05-11 19:01:39 +00:00
bors[bot]
e290891dd7
Merge #8801
8801: feat: Allow viewing the crate graph in a webview r=jonas-schievink a=jonas-schievink

This uses `dot` to render the crate graph as an SVD file, and displays it in a VS Code panel. For simple crate graphs, it works quite well:

![screenshot-2021-05-11-16:19:32](https://user-images.githubusercontent.com/1786438/117831361-c4a48980-b274-11eb-9276-240cdf6919aa.png)

Unfortunately, on rust-analyzer itself (and most medium-sized dependency graphs), `dot` runs for around a minute and then produces this mess:

![screenshot-2021-05-11-16:41:37](https://user-images.githubusercontent.com/1786438/117834831-c754ae00-b277-11eb-850b-138495dbeba8.png)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-11 18:02:31 +00:00
Jonas Schievink
d1aa6bbe75 Better node label/shapes 2021-05-11 19:50:01 +02:00
bors[bot]
6afd9b2b8d
Merge #8796
8796: internal: rewrite `#[derive]` removal to be based on AST (take 2) r=jonas-schievink a=jonas-schievink

Second attempt of https://github.com/rust-analyzer/rust-analyzer/pull/8443, this uses syntactical attribute offsets in `hir_expand`, and changes `attr.rs` to make those easy to derive.

This will make it easy to add similar attribute removal for attribute macros, unblocking them.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-11 17:47:45 +00:00
Jonas Schievink
5b3af25121 Only include workspace crates 2021-05-11 19:17:43 +02:00
DropDemBits
7fefac4bdc
Keep comments and attrs when extracting struct from enum variant 2021-05-11 11:07:47 -04:00
Jonas Schievink
b8d40a02a9 Document viewCrateGraph request 2021-05-11 16:45:51 +02:00
Jonas Schievink
9e6d9baf2e
Update crates/ide/src/view_crate_graph.rs
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-05-11 16:42:27 +02:00
Jonas Schievink
435c422963 Distinguish crates with identical name 2021-05-11 16:36:00 +02:00
Jonas Schievink
a85a2c4d15 Allow viewing the crate graph in a webview 2021-05-11 16:15:31 +02:00
bors[bot]
9fa9d166d8
Merge #8800
8800: feat: Make "pull assignments up" assist work in more cases r=Jesse-Bakker a=Jesse-Bakker

Fixes #8771

Co-authored-by: Jesse Bakker <github@jessebakker.com>
2021-05-11 13:14:55 +00:00
Jesse Bakker
5f37e34406 Make "pull assignments up" assist work in more cases 2021-05-11 15:14:23 +02:00
Jade
dc63fea427 Add basic support for array lengths in types
This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?
2021-05-11 05:25:19 -07:00
bors[bot]
77518991b8
Merge #8798
8798: internal: use modern resolever r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-11 10:07:25 +00:00
Aleksey Kladov
4b5600b2e8 internal: use modern resolever
I don't think this affects us, but better to stick to modern
practicies.
2021-05-11 13:06:35 +03:00
Jonas Schievink
8ea9d939d2 Rewrite #[derive] removal to be based on AST 2021-05-10 22:54:17 +02:00
John Renner
7ae3967e57 Formatting and docs 2021-05-10 13:34:09 -07:00
bors[bot]
77f0c92fd8
Merge #8794
8794: Give MergeBehaviour variants better names r=Veykril a=Veykril

I never really liked the variant names I gave this enum from the beginning and then I found out about rustfmt's `imports_granularity` config:

> imports_granularity
>
> How imports should be grouped into use statements. Imports will be merged or split to the configured level of granularity.
> 
>     Default value: Preserve
>     Possible values: Preserve, Crate, Module, Item
>     Stable: No

I personally prefer using `crate` over `full` and `module` over last, they seem more descriptive. Keeping these similar between tooling also seems like a good plus point to me.

We might even wanna take over the entire enum at some point if we have a `format/cleanup imports` assists in the future which would probably want to also have the `preserve` and `item` options.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-10 20:10:59 +00:00
Lukas Wirth
59c2efe4b6 Update docs 2021-05-10 22:10:12 +02:00
John Renner
c3ba1f14fa Allow semantic tokens for strings to be disabled 2021-05-10 13:09:38 -07:00
Jonas Schievink
da08198bc9 Rewrite attr.rs to allow using syntax-based indices 2021-05-10 21:50:42 +02:00
Lukas Wirth
6a8d47e7f0 Give MergeBehaviour variants better names 2021-05-10 21:14:59 +02:00
bors[bot]
c7edc38cd0
Merge #8793
8793: Corrected 2 typos on line 83 r=Veykril a=mixio



Co-authored-by: mixio <38652479+mixio@users.noreply.github.com>
2021-05-10 18:08:26 +00:00
mixio
aa9002c68a
Corrected 2 typos on line 83 2021-05-10 20:05:32 +02:00
Jonas Schievink
a87bec5148 Move AttrId back into hir_def 2021-05-10 16:35:06 +02:00
bors[bot]
07cea5e709
Merge #8791
8791: feat: auto-indent use tree lists r=jonas-schievink a=jonas-schievink

![Peek 2021-05-10 15-20](https://user-images.githubusercontent.com/1786438/117665627-53e16c80-b1a3-11eb-8906-1b88b394367b.gif)


bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-10 13:21:33 +00:00
Jonas Schievink
e718c6b3e8 feat: auto-indent use tree lists 2021-05-10 15:10:56 +02:00
bors[bot]
17038756ba
Merge #8790
8790: fix: fix manual rendering r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-10 12:44:17 +00:00
Aleksey Kladov
078c8f7488 fix: fix manual rendering
We add `// see the other repo` comments before headers (==). This one isn't a header, but a closing of the example block.
2021-05-10 15:43:01 +03:00
bors[bot]
619eb96153
Merge #8789
8789: simplify r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-10 12:26:52 +00:00
Aleksey Kladov
bf26e13cd2 simplify 2021-05-10 15:25:56 +03:00
bors[bot]
fd109fb587
Merge #8784
8784: feat: auto-insert `}` when typing `{` in use item r=jonas-schievink a=jonas-schievink

![Peek 2021-05-09 22-14](https://user-images.githubusercontent.com/1786438/117585742-45983f80-b114-11eb-80fc-d44f480fd012.gif)

cc https://github.com/rust-analyzer/rust-analyzer/issues/8636

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-09 20:17:37 +00:00
Jonas Schievink
64f97fb2ad feat: auto-insert } when typing { in use item 2021-05-09 22:12:58 +02:00
bors[bot]
75a5c0a534
Merge #8783
8783: internal: introduce `ast::make::ext` module with common shortcuts r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 16:56:02 +00:00
Aleksey Kladov
4f3c0adc5a internal: introduce ast::make::ext module with common shortcuts
There's a tension between keeping a well-architectured minimal
orthogonal set of constructs, and providing convenience functions.
Relieve this pressure by introducing an dedicated module for
non-orthogonal shortcuts.

This is inspired by the django.shortcuts module which serves a similar
purpose architecturally.
2021-05-09 19:55:43 +03:00
bors[bot]
2fe329db48
Merge #8782
8782: internal: fix make API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 16:23:03 +00:00
Aleksey Kladov
680a0d54e4 internal: fix make API 2021-05-09 19:22:33 +03:00
bors[bot]
a3b034938e
Merge #8781
8781: internal: rewrite **Repalce impl Trait** assist to mutable syntax trees r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 15:55:42 +00:00
Aleksey Kladov
5342800147 internal: rewrite **Repalce impl Trait** assist to mutable syntax trees 2021-05-09 18:20:37 +03:00
Aleksey Kladov
984d20aad8 cleanups 2021-05-09 18:01:54 +03:00
Aleksey Kladov
d9c9f6dc2c cleanups 2021-05-09 17:58:03 +03:00
Aleksey Kladov
edeb492782 minor: fix test style 2021-05-09 17:47:02 +03:00
Aleksey Kladov
5637ce4250 fix: join lines doesn't add space before closing quote 2021-05-09 17:46:41 +03:00
bors[bot]
0900beeaa2
Merge #8776
8776: fix: fix unnecessary recomputations due to macros r=jonas-schievink a=jonas-schievink

This computes a macro's fragment kind eagerly (when the calling file is still available in parsed form) and stores it in the `MacroCallLoc`. This means that during expansion we no longer have to reparse the file containing the macro call, avoiding the unnecessary salsa dependencies (https://github.com/rust-analyzer/rust-analyzer/pull/8746#issuecomment-834776349).

Marking as draft until I manage to find a test for this problem, since for some reason `typing_inside_a_function_should_not_invalidate_expansions` does not catch this (which might indicate that I misunderstand the problem).

I've manually confirmed that this fixes the issue described in https://github.com/rust-analyzer/rust-analyzer/pull/8746#issuecomment-834776349:

```
    7ms - parse_query @ FileId(179)
   12ms - SourceBinder::to_module_def
       12ms - crate_def_map:wait
            5ms - item_tree_query (1 calls)
            7ms - ???
```

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-09 14:40:49 +00:00
Jonas Schievink
fd5a1d1765 Test that none of the macros are reparsed 2021-05-09 16:39:47 +02:00
bors[bot]
3f01edebec
Merge #8779
8779: fix: join lines doesn't add space before closing quote r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 14:19:39 +00:00
Aleksey Kladov
e0da3da0d9 fix: join lines doesn't add space before closing quote 2021-05-09 17:19:18 +03:00
bors[bot]
b43921cddd
Merge #8777
8777: Escape characters in builtin macros correctly r=edwin0cheng a=edwin0cheng

Fixes #8749

It is the same bug in #8560 but in our `quote!` macro. 

Because the "\" are adding exponentially in #8749 case, so the text is eat up all the memory. 

bors r+



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-05-09 12:01:35 +00:00
Edwin Cheng
01ce37c805 Escape characters in builtin macros correctly 2021-05-09 19:57:29 +08:00
bors[bot]
6c0cdc5f55
Merge #8774
8774: feat: Honor `.cargo/config.toml` r=matklad a=Veykril

![f1Gup1aiAn](https://user-images.githubusercontent.com/3757771/117545448-1dcaae00-b026-11eb-977a-0f35a5e3f2e0.gif)

Implements `cargo/.config` build target and cfg access by using unstable cargo options:

- `cargo config get` to read the target triple out of the config to pass to `cargo metadata` --filter-platform
- `cargo rustc --print` to read out the `rustc_cfgs`, this causes us to honor `rustflags` and the like.

If those commands fail, due to not having a nightly toolchain present for example, they will fall back to invoking rustc directly as we currently do.

I personally think it should be fine to use these unstable options as they are unlikely to change(even if they did it shouldn't be a problem due to the fallback) and don't burden the user if they do not have a nightly toolchain at hand since we fall back to the previous behaviour.

cc #8741
Closes #6604, Closes #5904, Closes #8430, Closes #8480

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-09 10:33:31 +00:00