Commit graph

16868 commits

Author SHA1 Message Date
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
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
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
Jonas Schievink
9cf8d325a2 Precompute macro fragment kind 2021-05-09 01:36:06 +02:00
bors[bot]
cf4d4f646b
Merge #8773
8773: fix: Correctly support SelfType when searching for usages r=Veykril a=Veykril

Fixes #7443

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-08 22:09:03 +00:00
Lukas Wirth
b7e6537935 Use RUSTC_BOOTSTRAP=1 instead of +nightly when discovering rust_cfgs throughs cargo 2021-05-09 00:07:04 +02:00
Lukas Wirth
3a346412cf Don't handle Self as a usage for TraitDefs 2021-05-08 23:35:18 +02:00
bors[bot]
6cd11bbbc2
Merge #8775
8775: Add `=` to pattern recovery r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-08 21:14:47 +00:00
Lukas Wirth
174f043c8d Add = to pattern recovery 2021-05-08 23:14:08 +02:00
Lukas Wirth
04717b9bd2 Fix builtintype def_to_ty 2021-05-08 22:43:26 +02:00
Lukas Wirth
41f470fea8 Correctly support SelfType when searching for usages 2021-05-08 22:34:55 +02:00
bors[bot]
4e33cbc6ad
Merge #8772
8772: minor: remove dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-08 20:29:03 +00:00
Aleksey Kladov
8a7904127d minor: remove dead code 2021-05-08 23:28:36 +03:00
bors[bot]
304cdd7778
Merge #8770
8770: feat: add "mentoring instructions" test for pull up assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-08 20:20:09 +00:00
Aleksey Kladov
1ee12b5db1 feat: add "mentoring instructions" test for pull up assist 2021-05-08 23:19:08 +03:00
Aleksey Kladov
1755b57e1a internal: pull_assignment_up uses mutable trees 2021-05-08 23:11:42 +03:00
Aleksey Kladov
e603090961 minor: add missing test 2021-05-08 20:40:07 +03:00
bors[bot]
96c5df9b17
Merge #8769
8769: internal: removed dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-08 17:03:58 +00:00
Aleksey Kladov
880ddddfe6 dead code 2021-05-08 20:02:48 +03:00
Aleksey Kladov
2a4819ca19 Disable more incremental 2021-05-08 20:00:15 +03:00
bors[bot]
18d026a2a6
Merge #8768
8768: internal: remove one more usage of SyntaxRewriter r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-08 16:51:09 +00:00
Lukas Wirth
8989fb8315 Discover rustc_cfg through unstable cargo options 2021-05-08 18:17:18 +02:00
Aleksey Kladov
7ab4fd7628 internal: remove one more usage of SyntaxRewriter 2021-05-08 15:45:17 +03:00