]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #7956
bors[bot] [Fri, 12 Mar 2021 14:45:04 +0000 (14:45 +0000)]
Merge #7956

7956: Add assist to convert for_each into for loops r=Veykril a=SaiintBrisson

This PR resolves #7821.
Adds an assist to that converts an `Iterator::for_each` into a for loop:

```rust
fn main() {
    let vec = vec![(1, 2), (2, 3), (3, 4)];
    x.iter().for_each(|(x, y)| {
        println!("x: {}, y: {}", x, y);
    })
}
```
becomes
```rust
fn main() {
    let vec = vec![(1, 2), (2, 3), (3, 4)];
    for (x, y) in x.iter() {
        println!("x: {}, y: {}", x, y);
    });
}
```

Co-authored-by: Luiz Carlos Mourão Paes de Carvalho <luizcarlosmpc@gmail.com>
Co-authored-by: Luiz Carlos <luizcarlosmpc@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix convert_iter_for_each_to_for doctest
Lukas Wirth [Fri, 12 Mar 2021 14:41:08 +0000 (15:41 +0100)]
Fix convert_iter_for_each_to_for doctest

3 years agoMerge #7904
bors[bot] [Fri, 12 Mar 2021 14:23:32 +0000 (14:23 +0000)]
Merge #7904

7904: Improved completion sorting r=JoshMcguigan a=JoshMcguigan

I was working on extending #3954 to apply completion scores in more places (I'll have another PR open for that soon) when I discovered that actually completion sorting was not working for me at all in `coc.nvim`. This led me down a bit of a rabbit hole of how coc and vs code each sort completion items.

Before this PR, rust-analyzer was setting the `sortText` field on completion items to `None` if we hadn't applied any completion score for that item, or to the label of the item with a leading whitespace character if we had applied any completion score. Completion score is defined in rust-analyzer as an enum with two variants, `TypeMatch` and `TypeAndNameMatch`.

In vs code the above strategy works, because if `sortText` isn't set [they default it to the label](https://github.com/microsoft/vscode/commit/b4ead4ed665e1ce2e58d8329c682f78da2d4e89d). However, coc [does not do this](https://github.com/neoclide/coc.nvim/blob/e211e361475a38b146a903b9b02343551c6cd372/src/completion/complete.ts#L245).

I was going to file a bug report against coc, but I read the [LSP spec for the `sortText` field](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion) and I feel like it is ambiguous and coc could claim what they do is a valid interpretation of the spec.

Further, the existing rust-analyzer behavior of prepending a leading whitespace character for completion items with any completion score does not handle sorting `TypeAndNameMatch` completions above `TypeMatch` completions. They were both being treated the same.

The first change this PR makes is to set the `sortText` field to either "1" for `TypeAndNameMatch` completions, "2" for `TypeMatch` completions, or "3" for completions which are neither of those. This change works around the potential ambiguity in the LSP spec and fixes completion sorting for users of coc. It also allows `TypeAndNameMatch` items to be sorted above just `TypeMatch` items (of course both of these will be sorted above completion items without a score).

The second change this PR makes is to use the actual completion scores for ref matches. The existing code ignored the actual score and always assumed these would be a high priority completion item.

#### Before

Here coc just sorts based on how close the items are in the file.

![image](https://user-images.githubusercontent.com/22216761/110249880-46063580-7f2d-11eb-9233-91a2bbd48238.png)

#### After

Here we correctly get `zzz` first, since that is both a type and name match. Then we get `ccc` which is just a type match.

![image](https://user-images.githubusercontent.com/22216761/110249883-4e5e7080-7f2d-11eb-9269-a3bc133fdee7.png)

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agoupdate relevance score u8 -> u32
Josh Mcguigan [Fri, 12 Mar 2021 14:08:07 +0000 (06:08 -0800)]
update relevance score u8 -> u32

3 years agoadd relevance score test
Josh Mcguigan [Fri, 12 Mar 2021 04:39:25 +0000 (20:39 -0800)]
add relevance score test

3 years agoremove unused CompletionScore enum
Josh Mcguigan [Fri, 12 Mar 2021 03:13:27 +0000 (19:13 -0800)]
remove unused CompletionScore enum

3 years agoadd completion relevance score
Josh Mcguigan [Fri, 12 Mar 2021 03:11:14 +0000 (19:11 -0800)]
add completion relevance score

3 years agoMerge #7980
bors[bot] [Fri, 12 Mar 2021 14:11:42 +0000 (14:11 +0000)]
Merge #7980

7980: Fix remaining references to `cargo xtask codegen` r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix remaining references to `cargo xtask codegen`
Lukas Wirth [Fri, 12 Mar 2021 14:10:33 +0000 (15:10 +0100)]
Fix remaining references to `cargo xtask codegen`

3 years agofix: generated test fixture
Luiz Carlos Mourão Paes de Carvalho [Fri, 12 Mar 2021 11:53:57 +0000 (08:53 -0300)]
fix: generated test fixture

3 years agofix: replace doc-comments with normal comments
Luiz Carlos [Fri, 12 Mar 2021 11:44:03 +0000 (08:44 -0300)]
fix: replace doc-comments with normal comments

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agorefactor: refactored and reduced assist code
Luiz Carlos Mourão Paes de Carvalho [Fri, 12 Mar 2021 11:06:50 +0000 (08:06 -0300)]
refactor: refactored and reduced assist code

3 years agoMerge #7978
bors[bot] [Fri, 12 Mar 2021 09:23:04 +0000 (09:23 +0000)]
Merge #7978

7978: Unify naming r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoUnify naming
Aleksey Kladov [Fri, 12 Mar 2021 09:12:32 +0000 (12:12 +0300)]
Unify naming

3 years agoMerge #7974
bors[bot] [Fri, 12 Mar 2021 08:41:16 +0000 (08:41 +0000)]
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>
3 years agouse references in CompletionItem's builder
yonip23 [Thu, 11 Mar 2021 15:46:41 +0000 (17:46 +0200)]
use references in CompletionItem's builder

3 years agoMerge #7972
bors[bot] [Thu, 11 Mar 2021 10:41:00 +0000 (10:41 +0000)]
Merge #7972

7972: fix: add semicolon after type ascription r=matklad a=conradludgate

Fixes #7971

Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
3 years agofix: add semicolon after type ascription
Conrad Ludgate [Thu, 11 Mar 2021 10:36:45 +0000 (10:36 +0000)]
fix: add semicolon after type ascription

3 years agoMerge #7969
bors[bot] [Wed, 10 Mar 2021 21:29:05 +0000 (21:29 +0000)]
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>
3 years agoReturn original text range in PrepareRename responses when inside macro
Lukas Wirth [Wed, 10 Mar 2021 21:26:41 +0000 (22:26 +0100)]
Return original text range in PrepareRename responses when inside macro

3 years agoMerge #7967
bors[bot] [Wed, 10 Mar 2021 20:07:53 +0000 (20:07 +0000)]
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>
3 years agoUse expect-test for builtin macro/derive tests
Jonas Schievink [Wed, 10 Mar 2021 20:05:02 +0000 (21:05 +0100)]
Use expect-test for builtin macro/derive tests

3 years agoMerge #7965
bors[bot] [Wed, 10 Mar 2021 18:59:19 +0000 (18:59 +0000)]
Merge #7965

7965: cargo update and lexer r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agocargo update and lexer
kjeremy [Wed, 10 Mar 2021 18:47:12 +0000 (13:47 -0500)]
cargo update and lexer

3 years agoMerge #7964
bors[bot] [Wed, 10 Mar 2021 18:46:58 +0000 (18:46 +0000)]
Merge #7964

7964: Implement builtin `cfg!` macro r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agofix: remove semicolon
Luiz Carlos Mourão Paes de Carvalho [Wed, 10 Mar 2021 18:43:57 +0000 (15:43 -0300)]
fix: remove semicolon

3 years agoImplement builtin `cfg!` macro
Jonas Schievink [Wed, 10 Mar 2021 18:43:03 +0000 (19:43 +0100)]
Implement builtin `cfg!` macro

3 years agoMerge #7961
bors[bot] [Wed, 10 Mar 2021 17:06:11 +0000 (17:06 +0000)]
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>
3 years agoadd user docs for ssr assist
Josh Mcguigan [Wed, 10 Mar 2021 16:11:16 +0000 (08:11 -0800)]
add user docs for ssr assist

3 years agoMerge #7959
bors[bot] [Wed, 10 Mar 2021 15:35:10 +0000 (15:35 +0000)]
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>
3 years agoPrefer names from outer DefMap over extern prelude
Jonas Schievink [Wed, 10 Mar 2021 15:33:18 +0000 (16:33 +0100)]
Prefer names from outer DefMap over extern prelude

3 years agoMerge #7958
bors[bot] [Wed, 10 Mar 2021 15:07:46 +0000 (15:07 +0000)]
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>
3 years agoAvoid double text edits when renaming mod declaration
Lukas Wirth [Wed, 10 Mar 2021 14:49:01 +0000 (15:49 +0100)]
Avoid double text edits when renaming mod declaration

3 years agoMerge #7874
bors[bot] [Wed, 10 Mar 2021 14:34:59 +0000 (14:34 +0000)]
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 :laughing:  - 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>
3 years agoadd apply ssr assist
Josh Mcguigan [Tue, 9 Mar 2021 05:11:28 +0000 (21:11 -0800)]
add apply ssr assist

3 years agoMerge #7957
bors[bot] [Wed, 10 Mar 2021 09:42:36 +0000 (09:42 +0000)]
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>
3 years agoFix labels for single import assists
Kirill Bulatov [Wed, 10 Mar 2021 09:30:25 +0000 (11:30 +0200)]
Fix labels for single import assists

3 years agofix: code formatting
Luiz Carlos Mourão Paes de Carvalho [Wed, 10 Mar 2021 03:32:25 +0000 (00:32 -0300)]
fix: code formatting

3 years agofix: tests should work for convert_iter_for_each_to_for
Luiz Carlos Mourão Paes de Carvalho [Wed, 10 Mar 2021 03:23:20 +0000 (00:23 -0300)]
fix:  tests should work for convert_iter_for_each_to_for

3 years agorefactor: create block expressions and for loops using make
Luiz Carlos Mourão Paes de Carvalho [Wed, 10 Mar 2021 02:55:26 +0000 (23:55 -0300)]
refactor: create block expressions and for loops using make

3 years agofeat: add expr_for_loop to make in syntax
Luiz Carlos Mourão Paes de Carvalho [Wed, 10 Mar 2021 02:54:35 +0000 (23:54 -0300)]
feat: add expr_for_loop to make in syntax

3 years agofeat: add assist to conver for_each into for loops
Luiz Carlos Mourão Paes de Carvalho [Wed, 10 Mar 2021 01:58:17 +0000 (22:58 -0300)]
feat: add assist to conver for_each into for loops

3 years agoMerge #7955
bors[bot] [Wed, 10 Mar 2021 01:32:40 +0000 (01:32 +0000)]
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>
3 years agoStop fetching ItemTrees for no reason
Jonas Schievink [Wed, 10 Mar 2021 01:32:16 +0000 (02:32 +0100)]
Stop fetching ItemTrees for no reason

3 years agoMerge #6822
bors[bot] [Tue, 9 Mar 2021 20:57:04 +0000 (20:57 +0000)]
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>
3 years agouse doc-comments
Edwin Cheng [Tue, 9 Mar 2021 20:54:31 +0000 (04:54 +0800)]
use doc-comments

3 years agoMerge #7949
bors[bot] [Tue, 9 Mar 2021 19:31:22 +0000 (19:31 +0000)]
Merge #7949

7949: Compilation speed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoCompilation speed
Aleksey Kladov [Tue, 9 Mar 2021 19:30:58 +0000 (22:30 +0300)]
Compilation speed

3 years agoMerge #7948
bors[bot] [Tue, 9 Mar 2021 18:11:18 +0000 (18:11 +0000)]
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>
3 years agoDelete `ContainerId`
Jonas Schievink [Tue, 9 Mar 2021 18:09:02 +0000 (19:09 +0100)]
Delete `ContainerId`

3 years agoMerge #7878
bors[bot] [Tue, 9 Mar 2021 17:34:18 +0000 (17:34 +0000)]
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>
3 years agoStop using `ContainerId` in `AssocContainerId`
Jonas Schievink [Tue, 9 Mar 2021 17:27:16 +0000 (18:27 +0100)]
Stop using `ContainerId` in `AssocContainerId`

3 years agoCheck ancestor maps when computing traits in scope
Jonas Schievink [Tue, 9 Mar 2021 17:18:35 +0000 (18:18 +0100)]
Check ancestor maps when computing traits in scope

3 years agoRemove `item_scope` field from `Body`
Jonas Schievink [Fri, 5 Mar 2021 13:53:54 +0000 (14:53 +0100)]
Remove `item_scope` field from `Body`

3 years agoUse `body.block_scopes` in `hir_ty` tests
Jonas Schievink [Fri, 5 Mar 2021 13:53:32 +0000 (14:53 +0100)]
Use `body.block_scopes` in `hir_ty` tests

3 years agoUse `body.block_scopes` to validate inner items
Jonas Schievink [Fri, 5 Mar 2021 13:15:26 +0000 (14:15 +0100)]
Use `body.block_scopes` to validate inner items

3 years agoUse `body.block_scopes` in `ChildBySource`
Jonas Schievink [Fri, 5 Mar 2021 13:08:36 +0000 (14:08 +0100)]
Use `body.block_scopes` in `ChildBySource`

3 years agoStore inner `BlockId`s in `Body`
Jonas Schievink [Fri, 5 Mar 2021 13:08:23 +0000 (14:08 +0100)]
Store inner `BlockId`s in `Body`

3 years agoChange `ChildBySource` to allow reusing `DynMap`
Jonas Schievink [Fri, 5 Mar 2021 13:06:09 +0000 (14:06 +0100)]
Change `ChildBySource` to allow reusing `DynMap`

3 years agoMerge #7945
bors[bot] [Tue, 9 Mar 2021 17:25:23 +0000 (17:25 +0000)]
Merge #7945

7945: Future proof completion scores r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoFuture proof completion scores
Aleksey Kladov [Tue, 9 Mar 2021 17:24:09 +0000 (20:24 +0300)]
Future proof completion scores

3 years agoMerge #7942
bors[bot] [Tue, 9 Mar 2021 16:23:51 +0000 (16:23 +0000)]
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>
3 years agoShow whether a binding is mutable or not on hover
Lukas Wirth [Tue, 9 Mar 2021 15:33:41 +0000 (16:33 +0100)]
Show whether a binding is mutable or not on hover

3 years agoMerge #7944
bors[bot] [Tue, 9 Mar 2021 16:05:23 +0000 (16:05 +0000)]
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>
3 years agoSelecting `&mut foo` completion now actually inserts `&mut`
Aleksey Kladov [Tue, 9 Mar 2021 16:04:27 +0000 (19:04 +0300)]
Selecting `&mut foo` completion now actually inserts `&mut`

3 years agoDon't show const items initializer expressions on hover
Lukas Wirth [Tue, 9 Mar 2021 15:33:23 +0000 (16:33 +0100)]
Don't show const items initializer expressions on hover

3 years agoCleanup auto-ref in completion
Aleksey Kladov [Tue, 9 Mar 2021 15:06:08 +0000 (18:06 +0300)]
Cleanup auto-ref in completion

3 years agoMerge #7941
bors[bot] [Tue, 9 Mar 2021 14:54:24 +0000 (14:54 +0000)]
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>
3 years agoMerge #7940
bors[bot] [Tue, 9 Mar 2021 14:46:10 +0000 (14:46 +0000)]
Merge #7940

7940: Cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoFix unused definitions not being document highlit
Lukas Wirth [Tue, 9 Mar 2021 14:45:31 +0000 (15:45 +0100)]
Fix unused definitions not being document highlit

3 years agoCleanup
Aleksey Kladov [Tue, 9 Mar 2021 14:44:27 +0000 (17:44 +0300)]
Cleanup

3 years agoCleanup
Aleksey Kladov [Tue, 9 Mar 2021 14:42:05 +0000 (17:42 +0300)]
Cleanup

3 years agoFix bad names
Aleksey Kladov [Tue, 9 Mar 2021 14:39:22 +0000 (17:39 +0300)]
Fix bad names

`res` should only be used for the result variable

3 years agoMerge #7873 #7933
bors[bot] [Tue, 9 Mar 2021 11:58:48 +0000 (11:58 +0000)]
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>
3 years agoImprove compilation speed
Aleksey Kladov [Tue, 9 Mar 2021 11:54:50 +0000 (14:54 +0300)]
Improve compilation speed

3 years agoMerge #7932
bors[bot] [Tue, 9 Mar 2021 11:48:08 +0000 (11:48 +0000)]
Merge #7932

7932: Make code less surprising r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMake code less surprising
Aleksey Kladov [Tue, 9 Mar 2021 11:43:05 +0000 (14:43 +0300)]
Make code less surprising

Theres no reason to have literal `\n\n` in the source code

3 years agoMerge #7931
bors[bot] [Tue, 9 Mar 2021 11:36:40 +0000 (11:36 +0000)]
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>
3 years agoUse `Type::new_with_resolver_inner` more
Jonas Schievink [Tue, 9 Mar 2021 11:31:16 +0000 (12:31 +0100)]
Use `Type::new_with_resolver_inner` more

3 years agoMerge #7927
bors[bot] [Tue, 9 Mar 2021 11:22:37 +0000 (11:22 +0000)]
Merge #7927

7927: Add more documentation for rustc_private r=matklad a=jyn514

Co-authored-by: Joshua Nelson <jyn514@gmail.com>
3 years agoMerge #7928
bors[bot] [Tue, 9 Mar 2021 11:13:17 +0000 (11:13 +0000)]
Merge #7928

7928: Add completion to turn x.err into Err(x) r=matklad a=duongdominhchau

PR for issue #7925

Co-authored-by: Duong Do Minh Chau <duongdominhchau@gmail.com>
3 years agoFix format
Duong Do Minh Chau [Tue, 9 Mar 2021 09:38:07 +0000 (16:38 +0700)]
Fix format

3 years agoMerge #7930
bors[bot] [Tue, 9 Mar 2021 09:03:07 +0000 (09:03 +0000)]
Merge #7930

7930: Clarify that all caps are experimental r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoClarify that all caps are experimental
Aleksey Kladov [Tue, 9 Mar 2021 09:02:20 +0000 (12:02 +0300)]
Clarify that all caps are experimental

3 years agoAdd trailing commas
Duong Do Minh Chau [Tue, 9 Mar 2021 09:00:06 +0000 (16:00 +0700)]
Add trailing commas

3 years agoUpdate the test to match the change
Duong Do Minh Chau [Tue, 9 Mar 2021 08:48:53 +0000 (15:48 +0700)]
Update the test to match the change

3 years agoAdd completion to turn x.err into Err(x)
Duong Do Minh Chau [Tue, 9 Mar 2021 08:36:41 +0000 (15:36 +0700)]
Add completion to turn x.err into Err(x)

3 years agoMerge #7898
bors[bot] [Mon, 8 Mar 2021 22:51:04 +0000 (22:51 +0000)]
Merge #7898

7898: generate_function assist: infer return type r=JoshMcguigan a=JoshMcguigan

This PR makes two changes to the generate function assist:

1. Attempt to infer an appropriate return type for the generated function
2. If a return type is inferred, and that return type is not unit, don't render the snippet

```rust
fn main() {
    let x: u32 = foo$0();
    //              ^^^ trigger the assist to generate this function
}

// BEFORE
fn foo() ${0:-> ()} {
    todo!()
}

// AFTER (only change 1)
fn foo() ${0:-> u32} {
    todo!()
}

// AFTER (change  1 and 2, note the lack of snippet around the return type)
fn foo() -> u32 {
    todo!()
}
```

These changes are made as two commits, in case we want to omit change 2. I personally feel like it is a nice change, but I could understand there being some opposition.

#### Pros of change 2
If we are able to infer a return type, and especially if that return type is not the unit type, the return type is almost as likely to be correct as the argument names/types. I think this becomes even more true as people learn how this feature works.

#### Cons of change 2

We could never be as confident about the return type as we are about the function argument types, so it is more likely a user will want to change that. Plus it is a confusing UX to sometimes have the cursor highlight the return type after triggering this assist and sometimes not have that happen.

#### Why omit unit type?

The assumption is that if we infer the return type as unit, it is likely just because of the current structure of the code rather than that actually being the desired return type. However, this is obviously just a heuristic and will sometimes be wrong. But being wrong here just means falling back to the exact behavior that existed before this PR.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agogenerate_function assist don't render snippet if ret type inferred
Josh Mcguigan [Sat, 6 Mar 2021 22:29:45 +0000 (14:29 -0800)]
generate_function assist don't render snippet if ret type inferred

3 years agoBetter strip turbofishes
Kirill Bulatov [Mon, 8 Mar 2021 12:59:54 +0000 (14:59 +0200)]
Better strip turbofishes

3 years agoAdd rustdocs and use better names
Kirill Bulatov [Mon, 8 Mar 2021 12:09:20 +0000 (14:09 +0200)]
Add rustdocs and use better names

3 years agoLess lifetines: derive SemanticsScope in place
Kirill Bulatov [Sun, 7 Mar 2021 22:25:45 +0000 (00:25 +0200)]
Less lifetines: derive SemanticsScope in place

3 years agoRebase leftovers
Kirill Bulatov [Sun, 7 Mar 2021 09:58:43 +0000 (11:58 +0200)]
Rebase leftovers

3 years agoCleanup
Kirill Bulatov [Thu, 4 Mar 2021 22:29:39 +0000 (00:29 +0200)]
Cleanup

3 years agoRestrict fuzzy qualifiers for now
Kirill Bulatov [Thu, 4 Mar 2021 22:11:07 +0000 (00:11 +0200)]
Restrict fuzzy qualifiers for now

3 years agoTest for fuzzy unresolved path maatch
Kirill Bulatov [Wed, 3 Mar 2021 22:10:20 +0000 (00:10 +0200)]
Test for fuzzy unresolved path maatch

3 years agoEnforce the located imports' order
Kirill Bulatov [Wed, 3 Mar 2021 21:59:56 +0000 (23:59 +0200)]
Enforce the located imports' order

3 years agoFix the completion labels and tests
Kirill Bulatov [Wed, 3 Mar 2021 21:55:21 +0000 (23:55 +0200)]
Fix the completion labels and tests

3 years agoWork towards better import labels
Kirill Bulatov [Tue, 2 Mar 2021 23:26:53 +0000 (01:26 +0200)]
Work towards better import labels

3 years agoProfile import_assets better
Kirill Bulatov [Mon, 1 Mar 2021 12:27:07 +0000 (14:27 +0200)]
Profile import_assets better