Commit Graph

15658 Commits

Author SHA1 Message Date
Luiz Carlos Mourão Paes de Carvalho
f67861310c refactor: refactored and reduced assist code 2021-03-12 08:06:50 -03:00
bors[bot]
c0e9530fd0
Merge #7978
7978: Unify naming r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-12 09:23:04 +00:00
Aleksey Kladov
7e217a42e1 Unify naming 2021-03-12 12:22:45 +03:00
bors[bot]
c01ef6eaba
Merge #7974
7974: use references in CompletionItem's builder r=matklad a=yonip23

@matklad 
This is a follow up to [this pr](https://github.com/rust-analyzer/rust-analyzer/pull/7973)

Co-authored-by: yonip23 <yoni@codota.com>
2021-03-12 08:41:16 +00:00
yonip23
99c4a41cd1 use references in CompletionItem's builder 2021-03-11 17:46:41 +02:00
vsrs
49cdb2452a Fix LSP extensions documentation 2021-03-11 17:59:27 +03:00
vsrs
00e52e1f42 Add Feature: Related Tests comment 2021-03-11 17:58:45 +03:00
vsrs
daa2637486 Apply review suggestions 2021-03-11 17:39:41 +03:00
bors[bot]
db6364fecc
Merge #7972
7972: fix: add semicolon after type ascription r=matklad a=conradludgate

Fixes #7971

Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
2021-03-11 10:41:00 +00:00
Conrad Ludgate
233820d780
fix: add semicolon after type ascription 2021-03-11 10:36:45 +00:00
bors[bot]
610eba3320
Merge #7969
7969: Return original text range in PrepareRename responses when inside macro r=Veykril a=Veykril

bors r+
Issue found in #7968

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-10 21:29:05 +00:00
Lukas Wirth
98d2dbb90e Return original text range in PrepareRename responses when inside macro 2021-03-10 22:26:41 +01:00
bors[bot]
052fe49179
Merge #7967
7967: Use expect-test for builtin macro/derive tests r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-10 20:07:53 +00:00
Jonas Schievink
bc4ecb199b Use expect-test for builtin macro/derive tests 2021-03-10 21:05:02 +01:00
Jonas Schievink
7b1a0d5fb7 Diagnose files that aren't in the module tree 2021-03-10 20:30:20 +01:00
bors[bot]
6c32e2d8a0
Merge #7965
7965: cargo update and lexer r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2021-03-10 18:59:19 +00:00
kjeremy
08e0e9976d cargo update and lexer 2021-03-10 13:47:12 -05:00
bors[bot]
0b96f1a047
Merge #7964
7964: Implement builtin `cfg!` macro r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-10 18:46:58 +00:00
Luiz Carlos Mourão Paes de Carvalho
6236b1eaf8 fix: remove semicolon 2021-03-10 15:43:57 -03:00
Jonas Schievink
2b8674b37e Implement builtin cfg! macro 2021-03-10 19:43:03 +01:00
bors[bot]
f0e78f2ed6
Merge #7961
7961: add user docs for ssr assist r=JoshMcguigan a=JoshMcguigan

@matklad 

This is a small follow up on #7874, adding user docs for the SSR assist functionality. Since most other assists aren't handled this way I wasn't sure exactly how we wanted to document this, so feel free to suggest alternatives.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2021-03-10 17:06:11 +00:00
Josh Mcguigan
40587b08a0 add user docs for ssr assist 2021-03-10 09:04:47 -08:00
bors[bot]
b35559a246
Merge #7959
7959: Prefer names from outer DefMap over extern prelude r=jonas-schievink a=jonas-schievink

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

Just one more special case, how bad could it be.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-10 15:35:10 +00:00
Jonas Schievink
c2622c9228 Prefer names from outer DefMap over extern prelude 2021-03-10 16:33:18 +01:00
bors[bot]
83280ea574
Merge #7958
7958: Avoid double text edits when renaming mod declaration r=matklad a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/7916

See https://github.com/microsoft/vscode-languageserver-node/issues/752 for context

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-10 15:07:46 +00:00
Lukas Wirth
3af69b5359 Avoid double text edits when renaming mod declaration 2021-03-10 15:49:01 +01:00
bors[bot]
9dc13408f9
Merge #7874
7874: add apply ssr assist r=JoshMcguigan a=JoshMcguigan

This PR adds an `Apply SSR` assist which was briefly mentioned in #3186. It allows writing an ssr rule as a comment, and then applying that SSR via an assist. This workflow is much nicer than the default available via `coc-rust-analyzer` when iterating to find the proper replacement.

As currently implemented, this requires the ssr rule is written as a single line in the comment, and it doesn't require any kind of prefix. Anything which properly parses as a ssr rule will enable the assist. The benefit of requiring the ssr rule be on a single line is it allows for a workflow where the user has several rules written one after the other, possibly to be triggered in order, without having to try to parse multiple lines of text and determine where one rule ends and the next begins. The benefit of not requiring a prefix is less typing 😆  - plus, I think the chance of something accidentally parsing as an ssr rule is minimal.

I think a reasonable extension of this would be to allow either any ssr rule that fits on a single line, or any comment block which in its entirety makes up a single ssr rule (parsing a comment block containing multiple ssr rules and running them all would break the use case that currently works where a user writes multiple ssr rules then runs them each one by one in arbitrary order).

I've marked this as a draft because for some reason I am strugging to make the unit tests pass. It does work when I compile rust-analyzer and test it in my editor though, so I'm not sure what is going on.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2021-03-10 14:34:59 +00:00
Josh Mcguigan
09307be75b add apply ssr assist 2021-03-10 06:02:15 -08:00
bors[bot]
a9b1e5cde1
Merge #7957
7957: Fix labels for single import assists r=SomeoneToIgnore a=SomeoneToIgnore

Before: 
![image](https://user-images.githubusercontent.com/2690773/110609185-a26b8e00-8195-11eb-87be-d21b75817c22.png)

After:
![image](https://user-images.githubusercontent.com/2690773/110609198-a5667e80-8195-11eb-8c58-9ae19ba71905.png)


Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-03-10 09:42:36 +00:00
Kirill Bulatov
94bb9cb9ee Fix labels for single import assists 2021-03-10 11:30:25 +02:00
Luiz Carlos Mourão Paes de Carvalho
a224e0087d fix: code formatting 2021-03-10 00:32:25 -03:00
Luiz Carlos Mourão Paes de Carvalho
b7f97715a3 fix: tests should work for convert_iter_for_each_to_for 2021-03-10 00:23:20 -03:00
Luiz Carlos Mourão Paes de Carvalho
87dc9d1fcc refactor: create block expressions and for loops using make 2021-03-09 23:55:26 -03:00
Luiz Carlos Mourão Paes de Carvalho
61fb16577b feat: add expr_for_loop to make in syntax 2021-03-09 23:54:35 -03:00
Luiz Carlos Mourão Paes de Carvalho
eea21490e0 feat: add assist to conver for_each into for loops 2021-03-09 22:58:17 -03:00
bors[bot]
63715e1f73
Merge #7955
7955: Stop fetching ItemTrees for no reason r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-10 01:32:40 +00:00
Jonas Schievink
7beec8fda1 Stop fetching ItemTrees for no reason 2021-03-10 02:32:16 +01:00
bors[bot]
654313dbc7
Merge #6822
6822: Read version of rustc that compiled proc macro r=edwin0cheng a=jsomedon

Signed-off-by: Jay Somedon <jay.somedon@outlook.com>

This PR is to fix #6174.

I basically
* added two methods, `read_version` and `read_section`(used by `read_version`)
* two new crates `snap` and `object` to be used by those two methods

I just noticed that some part of code were auto-reformatted by rust-analyzer on file save. Does it matter?

Co-authored-by: Jay Somedon <jay.somedon@outlook.com>
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-09 20:57:04 +00:00
Edwin Cheng
ad34e79bb9 use doc-comments 2021-03-10 04:54:31 +08:00
bors[bot]
4bb120c7a6
Merge #7949
7949: Compilation speed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 19:31:22 +00:00
Aleksey Kladov
842d8ad9c8 Compilation speed 2021-03-09 22:30:58 +03:00
bors[bot]
a436863364
Merge #7948
7948: Delete `ContainerId` r=jonas-schievink a=jonas-schievink

Since block expressions containing items now have a `ModuleId`, there's no need to also treat `DefWithBodyId` as a potential item container. Since https://github.com/rust-analyzer/rust-analyzer/pull/7878, only the `ModuleId` variant of `ContainerId` was ever created, so just delete the thing and use `ModuleId` everywhere.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-09 18:11:18 +00:00
Jonas Schievink
b885e6bdee Delete ContainerId 2021-03-09 19:09:02 +01:00
bors[bot]
9a5c72d9f0
Merge #7878
7878: Remove `item_scope` field from `Body` r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/7632

Instead of storing an `ItemScope` filled with inner items, we store the list of `BlockId`s for all block expressions that are part of a `Body`. Code can then query the `block_def_map` for those.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2021-03-09 17:34:18 +00:00
Jonas Schievink
a430549aa6 Stop using ContainerId in AssocContainerId 2021-03-09 18:27:23 +01:00
Jonas Schievink
12f6bdcfd9 Check ancestor maps when computing traits in scope 2021-03-09 18:27:23 +01:00
Jonas Schievink
6be4f30cae Remove item_scope field from Body 2021-03-09 18:27:23 +01:00
Jonas Schievink
1da0a27626 Use body.block_scopes in hir_ty tests 2021-03-09 18:27:23 +01:00
Jonas Schievink
0cb46a9e8d Use body.block_scopes to validate inner items 2021-03-09 18:27:23 +01:00
Jonas Schievink
c12f7be8d3 Use body.block_scopes in ChildBySource 2021-03-09 18:27:23 +01:00