]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #7920
bors[bot] [Mon, 8 Mar 2021 15:40:48 +0000 (15:40 +0000)]
Merge #7920

7920: Cargo update r=kjeremy a=kjeremy

Chalk changes just a version # bump. There are no actual commits.

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoCargo update
kjeremy [Mon, 8 Mar 2021 15:39:11 +0000 (10:39 -0500)]
Cargo update

Chalk changes just a version # bump. There are no actual commits.

3 years agoMerge #7914
bors[bot] [Mon, 8 Mar 2021 11:58:39 +0000 (11:58 +0000)]
Merge #7914

7914: Make code completion "just work" in more cases r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMake code completion "just work" in more cases
Aleksey Kladov [Mon, 8 Mar 2021 11:52:16 +0000 (14:52 +0300)]
Make code completion "just work" in more cases

3 years agoMerge #7912
bors[bot] [Mon, 8 Mar 2021 11:15:17 +0000 (11:15 +0000)]
Merge #7912

7912: Dedupe import map results r=matklad a=SomeoneToIgnore

While debugging https://github.com/rust-analyzer/rust-analyzer/issues/7902, I've found that there are some duplicates are produced during the external dependencies lookup.

I've spotted at least some of the `indexed_value.value` duplicated when typed `Arc` and requested the completions for that, so I've also deduped the `IndexedValue`'s to avoid unnecessary computations.

This helps to show `Arc` in the completion suggestions in a zero dependency project and in `hir` module, but we loose it again in the `ide` module.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoDo not process indexed values more than once
Kirill Bulatov [Mon, 8 Mar 2021 10:06:15 +0000 (12:06 +0200)]
Do not process indexed values more than once

3 years agoDeduplicate search_dependencies results
Kirill Bulatov [Mon, 8 Mar 2021 09:48:51 +0000 (11:48 +0200)]
Deduplicate search_dependencies results

3 years agoMerge #7901
bors[bot] [Mon, 8 Mar 2021 09:41:21 +0000 (09:41 +0000)]
Merge #7901

7901: Make extension respect http proxy settings r=matklad a=kamyuentse

This patch makes vscode extension respect proxy settings when fetching release metadata and rust-analyzer binary.

Co-authored-by: Kam Y. Tse <kevin.xjy@gmail.com>
3 years agoMake extension respect http proxy settings
Kam Y. Tse [Sun, 7 Mar 2021 09:55:43 +0000 (17:55 +0800)]
Make extension respect http proxy settings

3 years agoMerge #7889
bors[bot] [Sun, 7 Mar 2021 08:24:02 +0000 (08:24 +0000)]
Merge #7889

7889: Make group imports configurable r=lnicola a=asv1

Co-authored-by: asv <asv7c2@gmail.com>
3 years agoMake group imports configurable
asv [Sat, 6 Mar 2021 11:02:26 +0000 (13:02 +0200)]
Make group imports configurable

3 years agoMerge #7895
bors[bot] [Sun, 7 Mar 2021 08:13:27 +0000 (08:13 +0000)]
Merge #7895

7895: :arrow_up: xflags r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years ago:arrow_up: xflags
Aleksey Kladov [Sat, 6 Mar 2021 20:02:06 +0000 (23:02 +0300)]
:arrow_up: xflags

3 years agoMerge #7892
bors[bot] [Sun, 7 Mar 2021 00:32:56 +0000 (00:32 +0000)]
Merge #7892

7892: Fix TokenStream::from_str for input consisting of a single group with delimiter r=edwin0cheng a=kevinmehall

TokenStream holds a `tt::Subtree` but assumes its `delimiter` is always `None`. In particular, the iterator implementation iterates over the inner `token_trees` and ignores the `delimiter`.

However, `TokenStream::from_str` violated this assumption when the input consists of a single group by producing a Subtree with an outer delimiter, which was ignored as seen by a procedural macro.

`tt::Subtree` is just `pub delimiter: Option<Delimiter>, pub token_trees: Vec<TokenTree>`, so a Subtree that is statically guaranteed not to have a delimiter is just `Vec<TokenTree>`.

Fixes #7810
Fixes #7875

Co-authored-by: Kevin Mehall <km@kevinmehall.net>
3 years agoMerge #7899
bors[bot] [Sat, 6 Mar 2021 23:21:49 +0000 (23:21 +0000)]
Merge #7899

7899: Rename a few `crate_def_map`s to `def_map` r=jonas-schievink a=jonas-schievink

These could all be block `DefMap`s instead of crate-level `DefMap`s

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRename a few `crate_def_map`s to `def_map`
Jonas Schievink [Sat, 6 Mar 2021 23:20:13 +0000 (00:20 +0100)]
Rename a few `crate_def_map`s to `def_map`

These could all be block `DefMap`s instead of crate-level `DefMap`s

3 years agoMerge #7896
bors[bot] [Sat, 6 Mar 2021 20:22:36 +0000 (20:22 +0000)]
Merge #7896

7896: Only replace quotes in replace_string_with_char assist r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoOnly replace quotes in replace_string_with_char assist
Lukas Wirth [Sat, 6 Mar 2021 20:21:18 +0000 (21:21 +0100)]
Only replace quotes in replace_string_with_char assist

3 years agoMerge #7800
bors[bot] [Sat, 6 Mar 2021 20:01:50 +0000 (20:01 +0000)]
Merge #7800

7800: [WIP] 7708: Initial implementation of generate Default assist. r=Veykril a=chetankhilosiya

The Generate Default impl from new function.

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years ago7708: rust ideomatic code fixes.
Chetan Khilosiya [Sat, 6 Mar 2021 19:56:05 +0000 (01:26 +0530)]
7708: rust ideomatic code fixes.

3 years agoMerge #7865
bors[bot] [Sat, 6 Mar 2021 19:54:36 +0000 (19:54 +0000)]
Merge #7865

7865: preserve escape sequences when replacing string with char r=Veykril a=jDomantas

Currently it replaces escape sequence with the actual value, which is very wrong for `"\n"`.

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
3 years agoMove TokenStream::to_string helpers inside the method
Kevin Mehall [Sat, 6 Mar 2021 19:30:43 +0000 (12:30 -0700)]
Move TokenStream::to_string helpers inside the method

3 years ago7708: handle both FamousDefs fixture and plain code.
Chetan Khilosiya [Sat, 6 Mar 2021 19:21:48 +0000 (00:51 +0530)]
7708: handle both FamousDefs fixture and plain code.

Also fix typo in example.

3 years ago7708: Added the updated implementation of is_default_implemented.
Chetan Khilosiya [Sat, 6 Mar 2021 17:45:00 +0000 (23:15 +0530)]
7708: Added the updated implementation of is_default_implemented.

The implementation uses hir create to find the implemented trait.

3 years ago7708: Added the logic to check is default impl is already present.
Chetan Khilosiya [Thu, 4 Mar 2021 18:26:18 +0000 (23:56 +0530)]
7708: Added the logic to check is default impl is already present.

Also added test cases for code present within module.

3 years ago7708: Updated generate default fn logic.
Chetan Khilosiya [Mon, 1 Mar 2021 20:04:18 +0000 (01:34 +0530)]
7708: Updated generate default fn logic.

3 years ago7708: Added the work for review comments.
Chetan Khilosiya [Mon, 1 Mar 2021 19:19:19 +0000 (00:49 +0530)]
7708: Added the work for review comments.

Also added 1 test case to test multiple struct blocks are present.

3 years ago7708: Fixed many documentaion example issues.
Chetan Khilosiya [Sat, 27 Feb 2021 21:00:19 +0000 (02:30 +0530)]
7708: Fixed many documentaion example issues.

3 years ago7708: Format code through rust-analyzer formatter.
Chetan Khilosiya [Sat, 27 Feb 2021 20:29:19 +0000 (01:59 +0530)]
7708: Format code through rust-analyzer formatter.

3 years ago7708: Initial implementation of generate Default assist.
Chetan Khilosiya [Sat, 27 Feb 2021 20:18:51 +0000 (01:48 +0530)]
7708: Initial implementation of generate Default assist.

The Generate Default impl from new function.

3 years agoMerge #7894
bors[bot] [Sat, 6 Mar 2021 18:44:34 +0000 (18:44 +0000)]
Merge #7894

7894: generate_function assist: convert arg names to lower snake case r=Veykril a=JoshMcguigan

This PR fixes one of the points listed by @TimoFreiberg in #3639. Specifically that all generated argument names should be converted to lower snake case.

```rust
struct BazBaz;

fn foo() {
    bar$0(BazBaz);
    // ^ when triggering the assist here, you get the output below
}

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

// AFTER
fn bar(baz_baz: BazBaz) ${0:-> ()} {
    todo!()
}
```

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agogenerate function assist convert arg names to lower snake case
Josh Mcguigan [Sat, 6 Mar 2021 17:53:21 +0000 (09:53 -0800)]
generate function assist convert arg names to lower snake case

3 years agoMake a placeholder panic message explain its purpose
Kevin Mehall [Sat, 6 Mar 2021 16:51:13 +0000 (09:51 -0700)]
Make a placeholder panic message explain its purpose

3 years agoRefactor TokenStream to hold Vec<TokenTree> instead of tt::Subtree
Kevin Mehall [Sat, 6 Mar 2021 16:46:32 +0000 (09:46 -0700)]
Refactor TokenStream to hold Vec<TokenTree> instead of tt::Subtree

`TokenStream` assumes that its subtree's delimeter is `None`, and this
should be encoded in the type system instead of having a delimiter field
that is mostly ignored.

`tt::Subtree` is just `pub delimiter: Option<Delimiter>, pub
token_trees: Vec<TokenTree>`, so a Subtree that is statically guaranteed
not to have a delimiter is just Vec<TokenTree>.

3 years agoFix TokenStream::from_str for input consisting of a single Group
Kevin Mehall [Sat, 6 Mar 2021 16:36:22 +0000 (09:36 -0700)]
Fix TokenStream::from_str for input consisting of a single Group

TokenStream holds a `tt::Subtree` but assumes its `delimiter` is always
`None`. In particular, the iterator implementation iterates over the
inner `token_trees` and ignores the `delimiter`.

However, `TokenStream::from_str` violated this assumption when the input
consists of a single Group by producing a Subtree with an outer
delimiter, which was ignored as seen by a procedural macro.

In this case, wrap an extra level of Subtree around it.

Fixes #7810
Fixes #7875

3 years agoMerge #7888
bors[bot] [Sat, 6 Mar 2021 10:38:57 +0000 (10:38 +0000)]
Merge #7888

7888: Add a line about code action commands to the CoC section of the docs r=lnicola a=flodiebold

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoAdd a line about code action commands to the CoC section of the docs
Florian Diebold [Sat, 6 Mar 2021 10:35:04 +0000 (11:35 +0100)]
Add a line about code action commands to the CoC section of the docs

3 years agoMerge #7887
bors[bot] [Fri, 5 Mar 2021 20:59:31 +0000 (20:59 +0000)]
Merge #7887

7887: Fix fail to parse :: for meta in mbe r=edwin0cheng a=edwin0cheng

fixes #7886

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix fail to parse :: for meta in mbe
Edwin Cheng [Fri, 5 Mar 2021 20:57:34 +0000 (04:57 +0800)]
Fix fail to parse :: for meta in mbe

3 years agoMerge #7884
bors[bot] [Fri, 5 Mar 2021 20:00:04 +0000 (20:00 +0000)]
Merge #7884

7884: Simplify TokenStream FromStr r=edwin0cheng a=edwin0cheng

Make sure `FromStr` ignore all `TokenMap` in all cases.

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoMerge #7869
bors[bot] [Fri, 5 Mar 2021 19:52:15 +0000 (19:52 +0000)]
Merge #7869

7869: Add support for deref assignments to "pull assignment up" assist. r=Veykril a=Jesse-Bakker

Fixes #7867

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoAdd support for deref assignments to "pull assignment up" assist.
Jesse Bakker [Thu, 4 Mar 2021 13:43:52 +0000 (14:43 +0100)]
Add support for deref assignments to "pull assignment up" assist.

Fixes #7867

3 years agoFix test
Edwin Cheng [Fri, 5 Mar 2021 19:30:22 +0000 (03:30 +0800)]
Fix test

3 years agoSimplify TokenStream FromStr
Edwin Cheng [Fri, 5 Mar 2021 19:17:36 +0000 (03:17 +0800)]
Simplify TokenStream FromStr

3 years agoMerge #7883
bors[bot] [Fri, 5 Mar 2021 18:49:29 +0000 (18:49 +0000)]
Merge #7883

7883: Make two calls virtual r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoMake two calls virtual
Laurențiu Nicola [Fri, 5 Mar 2021 18:25:24 +0000 (20:25 +0200)]
Make two calls virtual

3 years agoMerge #7882
bors[bot] [Fri, 5 Mar 2021 18:15:10 +0000 (18:15 +0000)]
Merge #7882

7882: cargo update r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agocargo update
kjeremy [Fri, 5 Mar 2021 18:14:29 +0000 (13:14 -0500)]
cargo update

3 years agoMerge #7881
bors[bot] [Fri, 5 Mar 2021 17:43:23 +0000 (17:43 +0000)]
Merge #7881

7881: Underengineer `cargo xtask install --client` r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoUnderengineer `cargo xtask install --client`
Aleksey Kladov [Fri, 5 Mar 2021 17:42:41 +0000 (20:42 +0300)]
Underengineer `cargo xtask install --client`

3 years agoMerge #7880
bors[bot] [Fri, 5 Mar 2021 16:24:32 +0000 (16:24 +0000)]
Merge #7880

7880: Honor snippet capability when using the extract function assist r=lnicola a=Arthamys

This fixes issue #7793

Co-authored-by: san <san@alien.parts>
3 years agoHonor snippet capability in extract function assist
san [Fri, 5 Mar 2021 12:21:31 +0000 (13:21 +0100)]
Honor snippet capability in extract function assist

3 years agoMerge #7870
bors[bot] [Fri, 5 Mar 2021 16:04:49 +0000 (16:04 +0000)]
Merge #7870

7870: Use chalk_ir::AdtId r=Veykril a=Veykril

It's a bit unfortunate that we got two AdtId's now(technically 3 with the alias in the chalk module but that one won't allow pattern matching), one from hir_def and one from chalk_ir(hir_ty). But the hir_ty/chalk one doesn't leave hir so it shouldn't be that bad I suppose. Though if I see this right this will happen for almost all IDs.

I imagine most of the intermediate changes to using chalk ids will turn out not too nice until the refactor is over.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7879
bors[bot] [Fri, 5 Mar 2021 14:12:19 +0000 (14:12 +0000)]
Merge #7879

7879: Fix some warnings r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFix some warnings
Laurențiu Nicola [Fri, 5 Mar 2021 13:59:50 +0000 (15:59 +0200)]
Fix some warnings

3 years agoMerge #7876
bors[bot] [Fri, 5 Mar 2021 08:52:07 +0000 (08:52 +0000)]
Merge #7876

7876: Cleanup install command r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoCleanup install command
Aleksey Kladov [Fri, 5 Mar 2021 08:51:32 +0000 (11:51 +0300)]
Cleanup install command

3 years agoFix regression where the client was not installed
Aleksey Kladov [Fri, 5 Mar 2021 08:12:40 +0000 (11:12 +0300)]
Fix regression where the client was not installed

3 years agoUse chalk_ir::AdtId
Lukas Wirth [Mon, 1 Mar 2021 20:57:39 +0000 (21:57 +0100)]
Use chalk_ir::AdtId

3 years agoMerge #7868
bors[bot] [Thu, 4 Mar 2021 12:39:36 +0000 (12:39 +0000)]
Merge #7868

7868: Migrate to user-centric config name for `cargo check` stuff r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMigrate to user-centric config name for `cargo check` stuff
Aleksey Kladov [Thu, 4 Mar 2021 11:52:36 +0000 (14:52 +0300)]
Migrate to user-centric config name for `cargo check` stuff

3 years agoMerge #7866
bors[bot] [Wed, 3 Mar 2021 22:05:38 +0000 (22:05 +0000)]
Merge #7866

7866: Complete `while let` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoComplete `while let`
Lukas Wirth [Wed, 3 Mar 2021 20:59:41 +0000 (21:59 +0100)]
Complete `while let`

3 years agopreserve escape sequences when replacing string with char
Domantas Jadenkus [Wed, 3 Mar 2021 21:20:18 +0000 (23:20 +0200)]
preserve escape sequences when replacing string with char

3 years agoDon't complete `super` unless its valid in paths
Lukas Wirth [Wed, 3 Mar 2021 20:58:48 +0000 (21:58 +0100)]
Don't complete `super` unless its valid in paths

3 years agoMerge #7863
bors[bot] [Wed, 3 Mar 2021 18:49:43 +0000 (18:49 +0000)]
Merge #7863

7863: Prevent renaming SelfType and BuiltinType r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoPrevent renaming SelfType and BuiltinType
Lukas Wirth [Wed, 3 Mar 2021 18:48:53 +0000 (19:48 +0100)]
Prevent renaming SelfType and BuiltinType

3 years agoReorder functions in rename.rs
Lukas Wirth [Wed, 3 Mar 2021 17:23:38 +0000 (18:23 +0100)]
Reorder functions in rename.rs

3 years agoMerge #7862
bors[bot] [Wed, 3 Mar 2021 18:11:56 +0000 (18:11 +0000)]
Merge #7862

7862: Remove incorrect broken test r=jonas-schievink a=jonas-schievink

`Struct` cannot be named at all in that position, since `super` doesn't
resolve to the block scope

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRemove incorrect broken test
Jonas Schievink [Wed, 3 Mar 2021 18:10:56 +0000 (19:10 +0100)]
Remove incorrect broken test

`Struct` cannot be named at all in that position, since `super` doesn't
resolve to the block scope

3 years agoMerge #7861
bors[bot] [Wed, 3 Mar 2021 13:29:56 +0000 (13:29 +0000)]
Merge #7861

7861: Special-case parenthesized and negated expressions in demorgan assist r=lnicola a=Jesse-Bakker

Fixes #7831

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoSpecial-case parenthesized and negated expressions in demorgan assist
Jesse Bakker [Wed, 3 Mar 2021 12:12:00 +0000 (13:12 +0100)]
Special-case parenthesized and negated expressions in demorgan assist

3 years agoMerge #7858
bors[bot] [Wed, 3 Mar 2021 08:23:38 +0000 (08:23 +0000)]
Merge #7858

7858: Clarify comparison rule r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoClarify comparison rule
Aleksey Kladov [Wed, 3 Mar 2021 08:23:05 +0000 (11:23 +0300)]
Clarify comparison rule

3 years agoMerge #7853
bors[bot] [Tue, 2 Mar 2021 20:34:24 +0000 (20:34 +0000)]
Merge #7853

7853: Update lexer r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUpdate lexer
kjeremy [Tue, 2 Mar 2021 20:33:22 +0000 (15:33 -0500)]
Update lexer

3 years agoMerge #7852
bors[bot] [Tue, 2 Mar 2021 17:42:20 +0000 (17:42 +0000)]
Merge #7852

7852: bump once_cell r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agobump once_cell
kjeremy [Tue, 2 Mar 2021 17:41:20 +0000 (12:41 -0500)]
bump once_cell

3 years agoMerge #7851
bors[bot] [Tue, 2 Mar 2021 15:46:02 +0000 (15:46 +0000)]
Merge #7851

7851: Compress tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoCompress tests
Aleksey Kladov [Tue, 2 Mar 2021 13:38:51 +0000 (16:38 +0300)]
Compress tests

3 years agoMerge #7824
bors[bot] [Tue, 2 Mar 2021 15:28:41 +0000 (15:28 +0000)]
Merge #7824

7824: feat: add type ascription r=matklad a=conradludgate

Based on this conversation: https://twitter.com/rust_analyzer/status/1366092401278922757
Built off of `add_turbo_fish`, finds the current `let` statement, checks if it has type/turbofish already and checks if the rhs function is generic.

There's one case I couldn't figure out how to implement that would be nice:

```rust
#[test]
fn add_type_ascription_function_result() {
    check_assist(
        add_type_ascription,
        r#"
fn make<T>() -> Result<T, &'static str> {}
fn main() {
    let x = make()$0;
}
"#,
        r#"
fn make<T>() -> Result<T, &'static str> {}
fn main() {
    let x: Result<${0:_}, &'static str> = make();
}
"#,
    );
}
```

The `Function::ret_type` fn wasn't returning anything much useful so I'm not sure how to identity such scenarios just yet

Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
3 years agochore: remove redundant tests
Conrad Ludgate [Tue, 2 Mar 2021 15:26:36 +0000 (15:26 +0000)]
chore: remove redundant tests

3 years agochore: remove deleted file path
Conrad Ludgate [Tue, 2 Mar 2021 15:02:47 +0000 (15:02 +0000)]
chore: remove deleted file path

3 years agochore: codegen
Conrad Ludgate [Tue, 2 Mar 2021 14:55:37 +0000 (14:55 +0000)]
chore: codegen

3 years agorefactor: re-use add_turbo_fish function
Conrad Ludgate [Tue, 2 Mar 2021 14:28:53 +0000 (14:28 +0000)]
refactor: re-use add_turbo_fish function

3 years agochore: fmt + docs
Conrad Ludgate [Mon, 1 Mar 2021 11:51:52 +0000 (11:51 +0000)]
chore: fmt + docs

3 years agochore: rename var
Conrad Ludgate [Mon, 1 Mar 2021 11:21:02 +0000 (11:21 +0000)]
chore: rename var

3 years agofeat: add type ascription assist
Conrad Ludgate [Mon, 1 Mar 2021 10:51:47 +0000 (10:51 +0000)]
feat: add type ascription assist

3 years agoMerge #7850
bors[bot] [Tue, 2 Mar 2021 14:19:45 +0000 (14:19 +0000)]
Merge #7850

7850: Don't add space when joining line to opening quote r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoDon't add space when joining line to opening quote
Aleksey Kladov [Tue, 2 Mar 2021 13:48:54 +0000 (16:48 +0300)]
Don't add space when joining line to opening quote

3 years agoMerge #7849
bors[bot] [Tue, 2 Mar 2021 13:54:56 +0000 (13:54 +0000)]
Merge #7849

7849: Fix xflags fallout r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoFix xflags fallout
Aleksey Kladov [Tue, 2 Mar 2021 13:50:03 +0000 (16:50 +0300)]
Fix xflags fallout

https://github.com/rust-analyzer/rust-analyzer/pull/7847#issuecomment-788920830

3 years agoMerge #7795
bors[bot] [Tue, 2 Mar 2021 13:46:50 +0000 (13:46 +0000)]
Merge #7795

7795: Show docs on hover for keywords and primitives r=matklad a=Veykril

![lAWFadkziX](https://user-images.githubusercontent.com/3757771/109369534-eeb4f500-789c-11eb-8f2b-2f9c4e129de3.gif)

It's a bit annoying that this requires the `SyntaxNode` and `Semantics` to be pulled through `hover_for_definition` just so we can get the `std` crate but I couldn't think of a better way.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoShow docs on hover for keywords and primitives
Lukas Wirth [Tue, 2 Mar 2021 13:41:01 +0000 (14:41 +0100)]
Show docs on hover for keywords and primitives

3 years agoMerge #7335 #7691
bors[bot] [Tue, 2 Mar 2021 13:32:06 +0000 (13:32 +0000)]
Merge #7335 #7691

7335: added region folding r=matklad a=LucianoBestia

Regions of code that you'd like to be folded can be wrapped with  `// #region` and `// #endregion` line comments.
This is called "Region Folding". It is originally available for many languages in VSCode. But Rust-analyzer has its own folding function and this is missing.
With this Pull Request I am suggesting a simple solution.
The regions are a special kind of comments, so I added a bit of code in the comment folding function.
The regex to match are: `^\s*//\s*#?region\b` and `^\s*//\s*#?endregion\b`.
The number of space characters is not important. There is an optional # character. The line can end with a name of the region.
Example:
```rust
// 1. some normal comment
// region: test
// 2. some normal comment
calling_function(x,y);
// endregion: test
```
I added a test for this new functionality in `folding_ranges.rs`.
Please, take a look and comment.
I found that these exact regexes are already present in the file `language-configuration.json`, but I don't find a way to read this configuration. So my regex is hardcoded in the code.

7691: Suggest name in extract variable r=matklad a=cpud36

Generate better default name in extract variable assist as was mentioned in issue #1587

# Currently supported
(in order of declining precedence)
1. Expr is argument to a function; use corresponding parameter name
2. Expr is result of a function or method call; use this function/method's name
3. Use expr type name (if possible)
4. Fallback to `var_name` otherwise

# Showcase

![generate_derive_variable_name_from_method](https://user-images.githubusercontent.com/4218373/108013304-72105400-701c-11eb-9f13-eec52e74d0cc.gif)
![generate_derive_variable_name_from_param](https://user-images.githubusercontent.com/4218373/108013305-72a8ea80-701c-11eb-957e-2214f7f005de.gif)

# Questions

* Should we more aggressively strip known types? E.g. we already strip `&T -> T`; should we strip `Option<T> -> T`, `Result<T, E> -> T`, and others?
* Integers and floats use `var_name` by default. Should we introduce a name, like `i`, `f` etc?
* Can we return a list and suggest a name when renaming(like IntelliJ does)?
* Should we add counters to remove duplicate variables? E.g. `type`, `type1`, type2`, etc.

Co-authored-by: Luciano Bestia <LucianoBestia@gmail.com>
Co-authored-by: Luciano <31509965+LucianoBestia@users.noreply.github.com>
Co-authored-by: Vladyslav Katasonov <cpud47@gmail.com>
3 years agostrip useless methods, and unary ops in suggest_name
Vladyslav Katasonov [Tue, 16 Feb 2021 21:42:58 +0000 (00:42 +0300)]
strip useless methods, and unary ops in suggest_name

3 years agopull out suggest_name::* to utils; enchance heuristics
Vladyslav Katasonov [Tue, 16 Feb 2021 20:48:15 +0000 (23:48 +0300)]
pull out suggest_name::* to utils; enchance heuristics

3 years agosuggest parameter name before function name
Vladyslav Katasonov [Tue, 16 Feb 2021 02:55:47 +0000 (05:55 +0300)]
suggest parameter name before function name

3 years agotry to suggest name when extracting variable
Vladyslav Katasonov [Tue, 16 Feb 2021 01:43:32 +0000 (04:43 +0300)]
try to suggest name when extracting variable

3 years agoMerge #7513
bors[bot] [Tue, 2 Mar 2021 13:20:47 +0000 (13:20 +0000)]
Merge #7513

7513: NFA parser for mbe matcher r=matklad a=edwin0cheng

Almost straight porting from rustc one, but a little bit slow :(

```
rust-analyzer analysis-stats -q .
```

From:
```log
Database loaded:     636.11ms, 277minstr
  crates: 36, mods: 594, decls: 11527, fns: 9017
Item Collection:     10.99s, 60ginstr
  exprs: 249618, ??ty: 2699 (1%), ?ty: 2101 (0%), !ty: 932
Inference:           28.94s, 123ginstr
Total:               39.93s, 184ginstr
```

To:
```log
Database loaded:     630.90ms, 277minstr
  crates: 36, mods: 594, decls: 11528, fns: 9018
Item Collection:     13.70s, 77ginstr
  exprs: 249482, ??ty: 2699 (1%), ?ty: 2101 (0%), !ty: 932
Inference:           30.27s, 133ginstr
Total:               43.97s, 211ginstr
```

Fixes #4777

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>