Commit graph

15531 commits

Author SHA1 Message Date
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
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
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
Jonas Schievink
13f4356d2f Store inner BlockIds in Body 2021-03-09 18:27:23 +01:00
Jonas Schievink
8da50c9077 Change ChildBySource to allow reusing DynMap 2021-03-09 18:27:23 +01:00
bors[bot]
84eed2136b
Merge #7945
7945: Future proof completion scores r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 17:25:23 +00:00
Aleksey Kladov
b2764a6641 Future proof completion scores 2021-03-09 20:24:09 +03:00
bors[bot]
c45ac6effe
Merge #7942
7942: Show whether a binding is mutable or not on hover r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-09 16:23:51 +00:00
Lukas Wirth
814d617d34 Show whether a binding is mutable or not on hover 2021-03-09 17:18:50 +01:00
bors[bot]
c2359608c9
Merge #7944
7944: Selecting `&mut foo` completion now actually inserts `&mut` r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 16:05:23 +00:00
Aleksey Kladov
73b9937e4e Selecting &mut foo completion now actually inserts &mut 2021-03-09 19:04:27 +03:00
Lukas Wirth
983726a45c Don't show const items initializer expressions on hover 2021-03-09 16:33:23 +01:00
Aleksey Kladov
12fe301a0c Cleanup auto-ref in completion 2021-03-09 18:06:08 +03:00
bors[bot]
472641fc5b
Merge #7941
7941: Fix unused definitions not being document highlit r=Veykril a=Veykril

Fixes #7939

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-09 14:54:24 +00:00
bors[bot]
ab99eff7b6
Merge #7940
7940: Cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 14:46:10 +00:00
Lukas Wirth
a1f080138a Fix unused definitions not being document highlit 2021-03-09 15:45:31 +01:00
Aleksey Kladov
abc0ed36bd Cleanup 2021-03-09 17:44:27 +03:00
Aleksey Kladov
444d67ae18 Cleanup 2021-03-09 17:42:05 +03:00
Aleksey Kladov
2cc278c6ff Fix bad names
`res` should only be used for the result variable
2021-03-09 17:39:22 +03:00
bors[bot]
21913d0fdb
Merge #7873 #7933
7873: Consider unresolved qualifiers during flyimport r=matklad a=SomeoneToIgnore

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

Takes unresolved qualifiers into account, providing better completions (or none, if the path is resolved or do not match).

Does not handle cases when both path qualifier and some trait has to be imported: there are many extra issues with those (such as overlapping imports, for instance) that will require large diffs to address.

Also does not do a fuzzy search on qualifier, that requires some adjustments in `import_map` for better queries and changes to the default replace range which also seems relatively big to include here.

![qualifier_completion](https://user-images.githubusercontent.com/2690773/110040808-0af8dc00-7d4c-11eb-83db-65af94e843bb.gif)


7933: Improve compilation speed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 11:58:48 +00:00
Aleksey Kladov
867fdf8f03 Improve compilation speed 2021-03-09 14:54:50 +03:00
bors[bot]
5e0e5302d5
Merge #7932
7932: Make code less surprising r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 11:48:08 +00:00
Aleksey Kladov
37b7b56821 Make code less surprising
Theres no reason to have literal `\n\n` in the source code
2021-03-09 14:47:42 +03:00
bors[bot]
ffba4c0dce
Merge #7931
7931: Use `Type::new_with_resolver_inner` more r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-09 11:36:40 +00:00