]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAlign config's API with usage
Aleksey Kladov [Wed, 6 Jan 2021 17:43:46 +0000 (20:43 +0300)]
Align config's API with usage

The config now is mostly immutable, optimize for that.

3 years agoMerge #7183
bors[bot] [Wed, 6 Jan 2021 17:29:18 +0000 (17:29 +0000)]
Merge #7183

7183: YAGNI active_resolve_capabilities r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoYAGNI active_resolve_capabilities
Aleksey Kladov [Wed, 6 Jan 2021 17:23:53 +0000 (20:23 +0300)]
YAGNI active_resolve_capabilities

This leaks a lot of LSP details into ide layer, which we want to avoid:

https://github.com/rust-analyzer/rust-analyzer/tree/c9cec381bcfd97e5f3536e31a9c546ab5c0665e6/docs/dev#lsp-independence

Additionally, all what this infra does is providing a toggle for
auto-import completion, but we already have one!

3 years agoMerge #7182
bors[bot] [Wed, 6 Jan 2021 17:16:04 +0000 (17:16 +0000)]
Merge #7182

7182: Replace last usages of difference with dissimilar r=matklad a=Jesse-Bakker

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoReplace last usages of difference with dissimilar
Jesse Bakker [Wed, 6 Jan 2021 17:13:29 +0000 (18:13 +0100)]
Replace last usages of difference with dissimilar

3 years agoMerge #7181
bors[bot] [Wed, 6 Jan 2021 16:41:22 +0000 (16:41 +0000)]
Merge #7181

7181: Document project_model::PackageData and project_model::TargetData r=arnaudgolfouse a=arnaudgolfouse

This PR adds some documentation for the `project_model` crate.

Some of the field descriptions were taken directly from their `cargo_metadata` counterpart :
- `PackageData` -> `cargo_metadata::Package`
- `TargetData` -> `cargo_metadata::Target`

Co-authored-by: Arnaud <arnaud.golfouse@free.fr>
3 years agoDocument `project_model::TargetData`
Arnaud [Wed, 6 Jan 2021 15:39:44 +0000 (16:39 +0100)]
Document `project_model::TargetData`

This adds a description for `TargetData` and all its fields.

3 years agoDocument `project_model::PackageData`
Arnaud [Wed, 6 Jan 2021 15:39:19 +0000 (16:39 +0100)]
Document `project_model::PackageData`

This adds a description for `PackageData` and all its fields.

3 years agoMerge #7180
bors[bot] [Wed, 6 Jan 2021 15:36:37 +0000 (15:36 +0000)]
Merge #7180

7180: More readable test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMore readable test
Aleksey Kladov [Wed, 6 Jan 2021 15:36:06 +0000 (18:36 +0300)]
More readable test

3 years agoMake `PackageData`, `TargetData` and `PackageDependency` public
Arnaud [Tue, 5 Jan 2021 18:02:13 +0000 (19:02 +0100)]
Make `PackageData`, `TargetData` and `PackageDependency` public

This makes them discoverable through documentation.
They were already publicly accessible through `Package` and `Target`.

3 years agoMerge #7179
bors[bot] [Wed, 6 Jan 2021 15:16:56 +0000 (15:16 +0000)]
Merge #7179

7179: Less confusing instr stat r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoLess confusing instr stat
Aleksey Kladov [Wed, 6 Jan 2021 15:16:04 +0000 (18:16 +0300)]
Less confusing instr stat

3 years agoMerge #7178
bors[bot] [Wed, 6 Jan 2021 13:33:25 +0000 (13:33 +0000)]
Merge #7178

7178: Better target for move module r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoBetter target for move module
Aleksey Kladov [Wed, 6 Jan 2021 13:24:47 +0000 (16:24 +0300)]
Better target for move module

3 years agoMerge #7177
bors[bot] [Wed, 6 Jan 2021 12:49:50 +0000 (12:49 +0000)]
Merge #7177

7177: Speed up snapshoting r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoSpeed up snapshoting
Aleksey Kladov [Wed, 6 Jan 2021 12:46:31 +0000 (15:46 +0300)]
Speed up snapshoting

Config can be fairly big, no need to deep clone it frequently

3 years agoMerge #7172
bors[bot] [Wed, 6 Jan 2021 12:40:34 +0000 (12:40 +0000)]
Merge #7172

7172: refactor config to be lossless & precise r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMore maintainable config
Aleksey Kladov [Wed, 6 Jan 2021 10:54:28 +0000 (13:54 +0300)]
More maintainable config

Rather than eagerly converting JSON, we losslessly keep it as is, and
change the shape of user-submitted data at the last moment.

This also allows us to remove a bunch of wrong Defaults

3 years agoMerge #7176
bors[bot] [Wed, 6 Jan 2021 11:32:53 +0000 (11:32 +0000)]
Merge #7176

7176: Attribute completion r=matklad a=FlowerBOII

Solve #7167.

I removed the optional args for the attributes ```deprecated```, ```must_use``` and ```should_panic```.
I also updated their respective tests.

Please let me know if I missed something.

Co-authored-by: FlowerBOII <42295129+FlowerBOII@users.noreply.github.com>
3 years agoChange the should_panic completion and his related attribute test
FlowerBOII [Wed, 6 Jan 2021 11:23:19 +0000 (12:23 +0100)]
Change the should_panic completion and his related attribute test

3 years agoRemove the args for the must_use attibute and change the related tests
FlowerBOII [Wed, 6 Jan 2021 11:04:23 +0000 (12:04 +0100)]
Remove the args for the must_use attibute and change the related tests

3 years agoUpdate deprecated test
FlowerBOII [Wed, 6 Jan 2021 10:07:57 +0000 (11:07 +0100)]
Update deprecated test

3 years agoRemove a part of the deprecated autocompletion
FlowerBOII [Wed, 6 Jan 2021 10:06:02 +0000 (11:06 +0100)]
Remove a part of the deprecated autocompletion

3 years agoMerge #7174
bors[bot] [Wed, 6 Jan 2021 09:03:38 +0000 (09:03 +0000)]
Merge #7174

7174: Normalize line endings when formatting r=matklad a=Jesse-Bakker

Fixes #7166

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoNormalize line endings when formatting
Jesse Bakker [Tue, 5 Jan 2021 21:29:53 +0000 (22:29 +0100)]
Normalize line endings when formatting

3 years agoMerge #7170
bors[bot] [Tue, 5 Jan 2021 14:52:21 +0000 (14:52 +0000)]
Merge #7170

7170: More maintainable caps config r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMore maintainable caps config
Aleksey Kladov [Tue, 5 Jan 2021 13:57:05 +0000 (16:57 +0300)]
More maintainable caps config

The idea here is that we preserve client's config as is, without
changes. This gets rid of state!

3 years agoMerge #7171
bors[bot] [Tue, 5 Jan 2021 14:46:47 +0000 (14:46 +0000)]
Merge #7171

7171: Emit diagnostics for unresolved item-level macros r=jonas-schievink a=jonas-schievink

We have been emitting macro *expansion* errors for macro calls in item position, as well as expansion and resolution errors for macro calls in bodies. This fills in the last gap, which is *resolution* errors for macro calls in item position (ie. those that name resolution cares about).

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoEmit diagnostics for unresolved item-level macros
Jonas Schievink [Tue, 5 Jan 2021 14:42:43 +0000 (15:42 +0100)]
Emit diagnostics for unresolved item-level macros

3 years agoMerge #7168
bors[bot] [Tue, 5 Jan 2021 12:51:38 +0000 (12:51 +0000)]
Merge #7168

7168: Rename expr -> tail_expr r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoRename expr -> tail_expr
Aleksey Kladov [Tue, 5 Jan 2021 12:45:46 +0000 (15:45 +0300)]
Rename expr -> tail_expr

3 years agoMerge #7140
bors[bot] [Tue, 5 Jan 2021 12:04:35 +0000 (12:04 +0000)]
Merge #7140

7140: Store trait associated items in fst r=matklad a=SomeoneToIgnore

Store imported traits' associated function/methods and constants into `ImportMap.fst` and pefrorm the imports search on them.

This is a first step towards trait autoimport during completion functionality, the way I see it, after this PR, only a few major things are left to be done:

* store all traits' assoc items into fst, not only the ones in scope, as we do now. Any code pointers on how to do this are welcome 😄
* adjust a few modules in completions crate (`dot.rs`, `qualified_path.rs` at least) to query the import map, reusing the `import_assets` logic heavily

==
With the current import and autoimport implementations, it looks like for a single query, we're either interested in either associated items lookup or in all other `fst` contents lookup, but never both simultaneously.
I would rather not split `fst` in two but add another `Query` parameter to separate those, but let me know if you have any ideas.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoMove the test mark
Kirill Bulatov [Tue, 5 Jan 2021 12:03:58 +0000 (14:03 +0200)]
Move the test mark

3 years agoMerge #7131
bors[bot] [Tue, 5 Jan 2021 11:04:58 +0000 (11:04 +0000)]
Merge #7131

7131: Created an assist for inlining a function's body into its caller r=matklad a=Michael-F-Bryan

This introduces an `inline_function` assist which will convert code like this:

```rust
fn add(a: u32, b: u32) -> u32 { a + b }
fn main() {
    let x = add<|>(1, 2);
}
```

Into something like this:

```rust
fn add(a: u32, b: u32) -> u32 { a + b }
fn main() {
    let x = {
        let a = 1;
        let b = 2;
        a + b
    };
}
```

Fixes #6863.

Co-authored-by: Michael-F-Bryan <michaelfbryan@gmail.com>
3 years agoMerge #7162
bors[bot] [Tue, 5 Jan 2021 10:53:24 +0000 (10:53 +0000)]
Merge #7162

7162: Introduce queries to avoid problems when performing completion for enums with many variants r=matklad a=danielframpton

This change introduces two new queries to compute:
  1) attributes for all variants of an enum, and
  2) attributes for all fields of a variant.

The purpose of this change is to avoid the current n^2 behavior when rendering completion for variants (which prevents completion for enums with large numbers of variants).

Co-authored-by: Daniel Frampton <Daniel.Frampton@microsoft.com>
3 years agoMerge #7164
bors[bot] [Tue, 5 Jan 2021 10:10:45 +0000 (10:10 +0000)]
Merge #7164

7164: Allow `#anchor` linking of config options r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoAllow `#anchor` linking of config options
Aleksey Kladov [Tue, 5 Jan 2021 10:09:06 +0000 (13:09 +0300)]
Allow `#anchor` linking of config options

3 years agoMerge #7163
bors[bot] [Tue, 5 Jan 2021 09:32:34 +0000 (09:32 +0000)]
Merge #7163

7163: Use macos-latest for aarch64-apple-darwin releases r=lnicola a=lnicola

Our builds get queued for 40-50 minutes waiting for a `macos-11.0` runner, let's keep using the older OS.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoUse macos-latest for aarch64-apple-darwin releases
Laurențiu Nicola [Tue, 5 Jan 2021 09:15:12 +0000 (11:15 +0200)]
Use macos-latest for aarch64-apple-darwin releases

3 years agoIntroduce new queries to compute
Daniel Frampton [Mon, 4 Jan 2021 20:56:21 +0000 (12:56 -0800)]
Introduce new queries to compute
  1) the set of attributes for all variants of an enum, and
  2) the set of attributes for all fields of a variant.

This avoids the current n^2 behavior when rendering completion for variants, which
prevents completion for enums with large numbers of variants.

3 years agoMerge #7161
bors[bot] [Mon, 4 Jan 2021 22:03:35 +0000 (22:03 +0000)]
Merge #7161

7161: Cargo update to remove some dependencies r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoCargo update to remove some dependencies
kjeremy [Mon, 4 Jan 2021 22:02:16 +0000 (17:02 -0500)]
Cargo update to remove some dependencies

3 years agoMerge #7160
bors[bot] [Mon, 4 Jan 2021 21:07:50 +0000 (21:07 +0000)]
Merge #7160

7160: Get `hir::Function` return type r=flodiebold a=arnaudgolfouse

Hello !

As said in #7158, I noticed that `hir::Function` has no direct way of getting the return type, so this PR adds this functionality.

Co-authored-by: Arnaud <arnaud.golfouse@free.fr>
3 years agoMerge #7147
bors[bot] [Mon, 4 Jan 2021 20:36:13 +0000 (20:36 +0000)]
Merge #7147

7147: ssr: Allow replacing expressions with statements r=davidlattimore a=MarijnS95

Depends on #6587

Until that is merged, the diff is https://github.com/MarijnS95/rust-analyzer/compare/stmt..replace-expr-with-stmt

---

Now that statements can be matched and replaced (#6587) some usecases require expressions to be replaced with statements as well. This happens when something that can ambiguously be an expression or statement like `if` and loop blocks appear in the last position of a block, as trailing expression. In this case a replacement pattern of the form `if foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of statements but not if they (implicitly) end up in the trailing expression, where they are not wrapped by an EXPR_STMT (but the pattern and template are, as parsing only succeeds for the `stmt ==>> stmt` case).

Instead of adding two rules that match an expression - and emit duplicate matching errors - allow the template for expressions to be a statement if it fails to parse as an expression.

---

Another gross change that does not seem to break any tests currently, but perhaps a safeguard should be added to only allow this kind of replacement in blocks by "pushing" the replacement template to the statement list and clearing the trailing expression?

CC @davidlattimore

Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
3 years agoCreated an inline-function assist (fixes #6863)
Michael-F-Bryan [Sat, 2 Jan 2021 05:47:35 +0000 (13:47 +0800)]
Created an inline-function assist (fixes #6863)

3 years agoSmall helpers
Kirill Bulatov [Mon, 4 Jan 2021 20:01:35 +0000 (22:01 +0200)]
Small helpers

3 years agoRemove `RetType`
Arnaud [Mon, 4 Jan 2021 19:34:23 +0000 (20:34 +0100)]
Remove `RetType`

3 years agoDocument `hir::Function::ret_type`
Arnaud [Mon, 4 Jan 2021 17:59:37 +0000 (18:59 +0100)]
Document `hir::Function::ret_type`

This adds documentation for the newly added function. It might be a bit too
detailed, but I like it that way :)

3 years agoMake it possible to retrieve `hir::Function`'s return type
Arnaud [Mon, 4 Jan 2021 17:58:42 +0000 (18:58 +0100)]
Make it possible to retrieve `hir::Function`'s return type

This is done by adding a `ret_type` method to `hir::Function`.
I followed `assoc_fn_params` convention by creating a new `RetType` type,
that contains the actual return type accessible via a `ty` method.

3 years agoMerge #7159
bors[bot] [Mon, 4 Jan 2021 18:02:54 +0000 (18:02 +0000)]
Merge #7159

7159: Refactor mbe to reduce clone and copying r=edwin0cheng a=edwin0cheng

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoSimplify SubtreeTokenSource
Edwin Cheng [Mon, 4 Jan 2021 17:50:34 +0000 (01:50 +0800)]
Simplify SubtreeTokenSource

3 years agoRefactor TokenBuffer for reduc cloning
Edwin Cheng [Mon, 4 Jan 2021 16:22:42 +0000 (00:22 +0800)]
Refactor TokenBuffer for reduc cloning

3 years agoCode review fixes
Kirill Bulatov [Mon, 4 Jan 2021 16:33:05 +0000 (18:33 +0200)]
Code review fixes

3 years agoMerge #7157
bors[bot] [Mon, 4 Jan 2021 16:13:53 +0000 (16:13 +0000)]
Merge #7157

7157: Update crates r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUpdate crates
kjeremy [Mon, 4 Jan 2021 16:12:42 +0000 (11:12 -0500)]
Update crates

3 years agoReduce string copying
Edwin Cheng [Mon, 4 Jan 2021 16:11:56 +0000 (00:11 +0800)]
Reduce string copying

3 years agoDo not collect trait type aliases
Kirill Bulatov [Sun, 3 Jan 2021 14:16:09 +0000 (16:16 +0200)]
Do not collect trait type aliases

3 years agoIgnore associated items during unqialified path fuzzy completions
Kirill Bulatov [Sun, 3 Jan 2021 13:58:15 +0000 (15:58 +0200)]
Ignore associated items during unqialified path fuzzy completions

3 years agoSimplify
Kirill Bulatov [Sun, 3 Jan 2021 10:24:50 +0000 (12:24 +0200)]
Simplify

3 years agoProperly check assoc items lookup
Kirill Bulatov [Sun, 3 Jan 2021 10:08:08 +0000 (12:08 +0200)]
Properly check assoc items lookup

3 years agoAdd associated data into fst
Kirill Bulatov [Sat, 2 Jan 2021 00:05:09 +0000 (02:05 +0200)]
Add associated data into fst

3 years agoAdd a basic test for the trait fuzzy import
Kirill Bulatov [Thu, 31 Dec 2020 00:18:15 +0000 (02:18 +0200)]
Add a basic test for the trait fuzzy import

3 years agoMerge #7156
bors[bot] [Mon, 4 Jan 2021 15:41:56 +0000 (15:41 +0000)]
Merge #7156

7156: Rename extension config r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoRename extension config
Aleksey Kladov [Mon, 4 Jan 2021 15:39:15 +0000 (18:39 +0300)]
Rename extension config

3 years agoMerge #7154
bors[bot] [Mon, 4 Jan 2021 15:23:53 +0000 (15:23 +0000)]
Merge #7154

7154: Show goto type actions for Const and TypeParams r=matklad a=Veykril

Shows goto type actions for type parameters:
![Code_6hn3rowu9M](https://user-images.githubusercontent.com/3757771/103547890-42aaeb00-4ea5-11eb-8ac7-f166869af5f8.png)

Shows goto type actions for const parameters:
![Code_8UFCcbZL3z](https://user-images.githubusercontent.com/3757771/103547891-43438180-4ea5-11eb-91e8-50681e4d831e.png)

Also shows implementations for `Self`:
![Code_eQj1pWfser](https://user-images.githubusercontent.com/3757771/103547892-43438180-4ea5-11eb-9122-461f2e0fdd01.png)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7155
bors[bot] [Mon, 4 Jan 2021 15:04:23 +0000 (15:04 +0000)]
Merge #7155

7155: Fix x86_64-pc-windows-msvc artifact name r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFix x86_64-pc-windows-msvc artifact name
Laurențiu Nicola [Mon, 4 Jan 2021 15:02:17 +0000 (17:02 +0200)]
Fix x86_64-pc-windows-msvc artifact name

3 years agoMerge #7151
bors[bot] [Mon, 4 Jan 2021 14:57:18 +0000 (14:57 +0000)]
Merge #7151

7151: Allow download of aarch64-pc-windows-msvc binaries r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoShow GotoTypeAction for TypeParam
Lukas Wirth [Mon, 4 Jan 2021 14:44:19 +0000 (15:44 +0100)]
Show GotoTypeAction for TypeParam

3 years agoMerge #7153
bors[bot] [Mon, 4 Jan 2021 14:47:16 +0000 (14:47 +0000)]
Merge #7153

7153: rename exrtract_assignment -> pull r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoAllow download of aarch64-pc-windows-msvc binaries
Laurențiu Nicola [Mon, 4 Jan 2021 12:58:02 +0000 (14:58 +0200)]
Allow download of aarch64-pc-windows-msvc binaries

3 years agoShow GotoTypeAction for ConstParam
Lukas Wirth [Mon, 4 Jan 2021 14:19:09 +0000 (15:19 +0100)]
Show GotoTypeAction for ConstParam

3 years agoShow implementations when hovering over SelfType
Lukas Wirth [Mon, 4 Jan 2021 13:57:59 +0000 (14:57 +0100)]
Show implementations when hovering over SelfType

3 years agoMerge #7152
bors[bot] [Mon, 4 Jan 2021 13:44:21 +0000 (13:44 +0000)]
Merge #7152

7152: Implement hover for ConstParam r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agorename exrtract_assignment -> pull
Aleksey Kladov [Mon, 4 Jan 2021 13:38:34 +0000 (16:38 +0300)]
rename exrtract_assignment -> pull

Vertical code motions are conventionally called "pull up" / "push
down".

"extract" is used for introducing new names.

3 years agoFix HoverAction::Implementation typo
Lukas Wirth [Mon, 4 Jan 2021 13:24:37 +0000 (14:24 +0100)]
Fix HoverAction::Implementation typo

3 years agoImplement hover for ConstParam
Lukas Wirth [Mon, 4 Jan 2021 13:18:31 +0000 (14:18 +0100)]
Implement hover for ConstParam

3 years agoMerge #7149
bors[bot] [Mon, 4 Jan 2021 12:57:28 +0000 (12:57 +0000)]
Merge #7149

7149: Implement hovering for TypeParams r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7148
bors[bot] [Mon, 4 Jan 2021 11:29:06 +0000 (11:29 +0000)]
Merge #7148

7148: Build aarch64-pc-windows-msvc releases r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoImpl hovering for TypeParams
Lukas Wirth [Fri, 1 Jan 2021 23:05:51 +0000 (00:05 +0100)]
Impl hovering for TypeParams

3 years agoMerge #6587
bors[bot] [Mon, 4 Jan 2021 11:14:40 +0000 (11:14 +0000)]
Merge #6587

6587: SSR: Support statement matching and replacing r=davidlattimore a=MarijnS95

For #3186

Hi!

This is a smaller initial patchset that came up while working on support for statement lists (and my first time working on RA :grin:). It has me stuck on trailing semicolons for which I hope to receive some feedback. Matching (and replacing) `let` bindings with a trailing semicolon works fine, but trying to omit these (to make patterns more ergonomic) turns out more complex than expected.

The "optional trailing semicolon solution" implemented in this PR is ugly because `Matcher::attempt_match_token` should only consume a trailing `;` when parsing `let` bindings to prevent other code from breaking. That at the same time has a nasty side-effect of `;` ending up in the matched code: any replacements on that should include the trailing semicolon as well even if it was not in the pattern. A better example is in the tests:

https://github.com/rust-analyzer/rust-analyzer/blob/3ae1649c24a689473b874c331f5f176e5839978e/crates/ssr/src/tests.rs#L178-L184

The end result to achieve is (I guess) allowing replacement of let bindings without trailing semicolon like `let x = $a ==>> let x = 1` (but including them on both sides is still fine), and should make replacement in a macro call (where `foo!(let a = 2;)` for a `$x:stmt` is invalid syntax) possible as well. That should allow to enable/fix these tests:

https://github.com/rust-analyzer/rust-analyzer/blob/3ae1649c24a689473b874c331f5f176e5839978e/crates/ssr/src/tests.rs#L201-L214

A possible MVP of this PR might be to drop this optional `;' handling entirely and only allow an SSR pattern/template with semicolons on either side.

Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
3 years agoBuild aarch64-pc-windows-msvc releases
Laurențiu Nicola [Mon, 4 Jan 2021 10:04:58 +0000 (12:04 +0200)]
Build aarch64-pc-windows-msvc releases

3 years agossr: Allow replacing expressions with statements
Marijn Suijten [Sun, 3 Jan 2021 16:45:49 +0000 (17:45 +0100)]
ssr: Allow replacing expressions with statements

Now that statements can be matched and replaced (#6587) some usecases
require expressions to be replaced with statements as well. This happens
when something that can ambiguously be an expression or statement like
`if` and loop blocks appear in the last position of a block, as trailing
expression. In this case a replacement pattern of the form `if
foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of
statements but not if they (implicitly) end up in the trailing
expression, where they are not wrapped by an EXPR_STMT (but the pattern
and template are, as parsing only succeeds for the `stmt ==>> stmt`
case).

Instead of adding two rules that match an expression - and emit
duplicate matching errors - allow the template for expressions to be a
statement if it fails to parse as an expression.

3 years agoMerge #7113
bors[bot] [Sun, 3 Jan 2021 18:22:07 +0000 (18:22 +0000)]
Merge #7113

7113: Manual updates r=matklad a=tekul

Add some details on how to build the manual and some clarification on how to deal with "proc macro2 warnings.

For context, this arose from [this question](https://users.rust-lang.org/t/how-to-disable-rust-analyzer-proc-macro-warnings-in-neovim/53150) on users.rust-lang.org.

Co-authored-by: Luke Taylor <tekul.hs@gmail.com>
3 years agoMerge #7138
bors[bot] [Sun, 3 Jan 2021 18:14:12 +0000 (18:14 +0000)]
Merge #7138

7138: Support assignment to FieldExpr for extract_assignment assist r=matklad a=Jesse-Bakker

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoSupport assignment to FieldExpr for extract_assignment assist
Jesse Bakker [Sun, 3 Jan 2021 13:11:42 +0000 (14:11 +0100)]
Support assignment to FieldExpr for extract_assignment assist

3 years agoMerge #7139
bors[bot] [Sun, 3 Jan 2021 13:54:53 +0000 (13:54 +0000)]
Merge #7139

7139: Upgrade expect-test to 1.1 r=matklad a=Jesse-Bakker

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoUpgrade expect-test to 1.1
Jesse Bakker [Sun, 3 Jan 2021 13:43:29 +0000 (14:43 +0100)]
Upgrade expect-test to 1.1

3 years agossr: Add tests for raw LetStmt matching
Marijn Suijten [Tue, 17 Nov 2020 14:33:10 +0000 (15:33 +0100)]
ssr: Add tests for raw LetStmt matching

3 years agoparser,syntax: Add separate parser for stmt with optional semicolon
Marijn Suijten [Tue, 17 Nov 2020 19:02:46 +0000 (20:02 +0100)]
parser,syntax: Add separate parser for stmt with optional semicolon

Adjusting `grammar::fragments::stmt` to Optional or Yes will break
original functionality and tests.

3 years agoMerge #7137
bors[bot] [Sun, 3 Jan 2021 10:48:41 +0000 (10:48 +0000)]
Merge #7137

7137: Revert "Proper handling $crate and local_inner_macros" r=jonas-schievink a=jonas-schievink

Reverts rust-analyzer/rust-analyzer#7133

It caused a fairly significant performance regression.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRevert "Proper handling $crate and local_inner_macros"
Jonas Schievink [Sun, 3 Jan 2021 10:47:57 +0000 (11:47 +0100)]
Revert "Proper handling $crate and local_inner_macros"

3 years agosyntax,ssr: Implement statement parsing
Marijn Suijten [Tue, 17 Nov 2020 14:34:41 +0000 (15:34 +0100)]
syntax,ssr: Implement statement parsing

3 years agoMerge #7136
bors[bot] [Sun, 3 Jan 2021 09:58:32 +0000 (09:58 +0000)]
Merge #7136

7136: Fixed nested eager macro bug r=edwin0cheng a=edwin0cheng

fixes #7126

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFixed nested eager macro bug
Edwin Cheng [Sun, 3 Jan 2021 09:56:59 +0000 (17:56 +0800)]
Fixed nested eager macro bug

3 years agoMerge #7068
bors[bot] [Sun, 3 Jan 2021 09:03:15 +0000 (09:03 +0000)]
Merge #7068

7068: Add VSCode command to view the hir of a function body r=theotherphil a=theotherphil

Will fix https://github.com/rust-analyzer/rust-analyzer/issues/7061. Very rough initial version just to work out where I needed to wire everything up.

@matklad would you be happy merging a hir visualiser of some kind? If so, do you have any thoughts on what you'd like it show, and how?

I've spent very little time on this thus far, so I'm fine with throwing away the contents of this PR, but I want to avoid taking the time to make this more polished/interactive/useful only to discover that no-one else has any interest in this functionality.

![image](https://user-images.githubusercontent.com/1974256/103236081-bb58f700-493b-11eb-9d12-55ae1b870f8f.png)

Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
3 years agoMerge #7115
bors[bot] [Sun, 3 Jan 2021 08:56:17 +0000 (08:56 +0000)]
Merge #7115

7115: Migrate HasSource::source to return Option r=matklad a=nick96

I've made a start on fixing #6913 based on the provided work plan, migrating `HasSource::source` to return an `Option`. The simple cases are migrated but there are a few that I'm unsure exactly how they should be handled:

- Logging the processing of functions in `AnalysisStatsCmd::run`: In verbose mode it includes the path to the module containing the function and the syntax range. I've handled this with an if-let but would it be better to blow up here with `expect`? I'm not 100% on the code paths but if we're processing a function definition then the source should exist.

I've handled `source()` in all code paths as `None` being a valid return value but are there some cases where we should just blow up? Also, all I've done is bubble up the returned `None`s, there may be some places where we can recover and still provide something.

Co-authored-by: Nick Spain <nicholas.spain@stileeducation.com>
Co-authored-by: Nick Spain <nicholas.spain96@gmail.com>
3 years agoUse stdx::format_to instead of writeln
Phil Ellison [Sun, 3 Jan 2021 08:54:33 +0000 (08:54 +0000)]
Use stdx::format_to instead of writeln

3 years agoMerge #7128
bors[bot] [Sun, 3 Jan 2021 08:49:59 +0000 (08:49 +0000)]
Merge #7128

7128: Implement HasAttrs for GenericParam r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>