]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoSupport `if let` match guards
Jonas Schievink [Thu, 12 Aug 2021 22:21:42 +0000 (00:21 +0200)]
Support `if let` match guards

2 years agoMerge #9874
bors[bot] [Thu, 12 Aug 2021 19:45:06 +0000 (19:45 +0000)]
Merge #9874

9874: fix: Always add implicit `proc_macro` dependency r=jonas-schievink a=jonas-schievink

Even crates that don't set `proc-macro = true` are allowed to depend on `proc_macro` (just none of the APIs work when called outside of a proc macro).

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

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoAlways add implicit `proc_macro` dependency
Jonas Schievink [Thu, 12 Aug 2021 19:42:14 +0000 (21:42 +0200)]
Always add implicit `proc_macro` dependency

2 years agoMerge #9807
bors[bot] [Thu, 12 Aug 2021 17:55:29 +0000 (17:55 +0000)]
Merge #9807

9807: Implicit `Sized` bounds r=iDawer a=iDawer

This should close #8984

`hir_ty`:
- Type parameters, associated types and `impl Trait` are `Sized` by deafault except `Self` in a trait.
- Implicit `Sized` bound is added to end of predicate list. It does not check if such bound is present already. Also it does not track the bound is implicit.
- Allowed ambiguous unsize coercion if Chalk returns definite guidance.
- Allowed ambiguous autoderef if Chalk returns definite guidance.

`hir_def`:
- `ItemTree` pretty printing shows `?Sized` bounds.

`HirDisplay`:
- `impl Trait` with weird bounds rendered correctly.
- `Sized`/`?Sized` bounds are not shown if they are default.

### Perf
`./target/rust-analyzer-baseline_8a843113 -q analysis-stats --memory-usage .`
```
Database loaded:     1.63s, 287minstr, 91mb
  crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection:     26.80s, 73ginstr, 338mb
  exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 174
Inference:           50.28s, 116ginstr, 516mb
Total:               77.08s, 189ginstr, 855mb
```

`./target/rust-analyzer-sized-fixed_ambig_coercion-de074fe6 -q analysis-stats --memory-usage .`
```
Database loaded:     1.63s, 287minstr, 91mb
  crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection:     26.95s, 73ginstr, 338mb
  exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 166
Inference:           96.39s, 234ginstr, 543mb
Total:               123.33s, 307ginstr, 881mb
```

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2 years agoClean up
Dawer [Thu, 12 Aug 2021 14:31:00 +0000 (19:31 +0500)]
Clean up

2 years agoMerge #9869
bors[bot] [Thu, 12 Aug 2021 12:11:09 +0000 (12:11 +0000)]
Merge #9869

9869: Use term "method" on label for generating method impl r=Veykril a=rylev

When showing the user the `generate_function` assist, use the term "method" when generating a method instead of the term "function" (which is correct but maybe not the most appropriate in that context).

Co-authored-by: Ryan Levick <me@ryanlevick.com>
2 years agoUse term on label for generating method impl
Ryan Levick [Thu, 12 Aug 2021 11:59:08 +0000 (13:59 +0200)]
Use term  on label for generating method impl

2 years agoMerge #9863
bors[bot] [Thu, 12 Aug 2021 10:18:02 +0000 (10:18 +0000)]
Merge #9863

9863: feat: Generate default trait fn impl when generating `PartialEq` r=yoshuawuyts a=yoshuawuyts

Implements a default trait function body when generating the `PartialEq` trait for a type. Thanks!

r? `@veykril`

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2 years agoadd `make::ext::path_from_idents`
Yoshua Wuyts [Thu, 12 Aug 2021 10:17:09 +0000 (12:17 +0200)]
add `make::ext::path_from_idents`

2 years agoimplement feedback from review
Yoshua Wuyts [Thu, 12 Aug 2021 09:50:01 +0000 (11:50 +0200)]
implement feedback from review

2 years agorm remaining todo comment
Yoshua Wuyts [Wed, 11 Aug 2021 21:30:00 +0000 (23:30 +0200)]
rm remaining todo comment

2 years agoimprove codegen
Yoshua Wuyts [Wed, 11 Aug 2021 18:33:13 +0000 (20:33 +0200)]
improve codegen

2 years agofinishing touches
Yoshua Wuyts [Wed, 11 Aug 2021 18:04:05 +0000 (20:04 +0200)]
finishing touches

2 years agogen partialeq for tuple enums
Yoshua Wuyts [Wed, 11 Aug 2021 18:01:19 +0000 (20:01 +0200)]
gen partialeq for tuple enums

2 years agodedup PartialEq for Record enums
Yoshua Wuyts [Wed, 11 Aug 2021 17:40:47 +0000 (19:40 +0200)]
dedup PartialEq for Record enums

2 years agoAccept ambiguous unsize coercion only if it has definite guidance.
Dawer [Wed, 11 Aug 2021 17:09:32 +0000 (22:09 +0500)]
Accept ambiguous unsize coercion only if it has definite guidance.

2 years agoMerge #9862
bors[bot] [Wed, 11 Aug 2021 16:13:29 +0000 (16:13 +0000)]
Merge #9862

9862: internal: Fill out expected type for functional update syntax completion r=Veykril a=Veykril

Last part of https://github.com/rust-analyzer/rust-analyzer/issues/9839
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoFill out expected type for functional update syntax completion
Lukas Wirth [Wed, 11 Aug 2021 16:05:39 +0000 (18:05 +0200)]
Fill out expected type for functional update syntax completion

2 years agoMerge #9861
bors[bot] [Wed, 11 Aug 2021 15:53:09 +0000 (15:53 +0000)]
Merge #9861

9861: fix: `extract_variable` handles selection ranges better r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoextract_variable handles selection ranges better
Lukas Wirth [Wed, 11 Aug 2021 15:52:09 +0000 (17:52 +0200)]
extract_variable handles selection ranges better

2 years agogen PartialEq for Record enums
Yoshua Wuyts [Wed, 11 Aug 2021 15:15:12 +0000 (17:15 +0200)]
gen PartialEq for Record enums

Co-Authored-By: Ryan Levick <rylev@users.noreply.github.com>
2 years agoMerge #9860
bors[bot] [Wed, 11 Aug 2021 15:10:26 +0000 (15:10 +0000)]
Merge #9860

9860: fix: Fix extract_function tagging params as mut unnecessarily r=Veykril a=Veykril

Fixes #9822
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoFix extract_function tagging params as mut unnecessarily
Lukas Wirth [Wed, 11 Aug 2021 15:09:51 +0000 (17:09 +0200)]
Fix extract_function tagging params as mut unnecessarily

2 years agoMerge #9856
bors[bot] [Wed, 11 Aug 2021 11:53:25 +0000 (11:53 +0000)]
Merge #9856

9856: Show type actions on ranged type hover r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoShow type actions on ranged type hover
Lukas Wirth [Wed, 11 Aug 2021 11:39:36 +0000 (13:39 +0200)]
Show type actions on ranged type hover

2 years agoMerge #9854
bors[bot] [Wed, 11 Aug 2021 11:17:06 +0000 (11:17 +0000)]
Merge #9854

9854: internal: document that ascription is preferred to a turbo fish r=matklad a=matklad

bors r+
đŸ¤–

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: document that ascription is preferred to a turbo fish
Aleksey Kladov [Wed, 11 Aug 2021 11:16:15 +0000 (14:16 +0300)]
internal: document that ascription is preferred to a turbo fish

2 years agoMerge #9836
bors[bot] [Wed, 11 Aug 2021 09:54:09 +0000 (09:54 +0000)]
Merge #9836

9836: Refactor: quick clean-up of iteration idioms in the `vfs` crate r=matklad a=Some-Dood

This PR cleans up some of the iteration idioms used in the `vfs` crate. Most of the changes simply converted `for` loops into their `std::iter::Iterator`-method counterpart. Other changes required some inversion of logic to accommodate for better short-circuiting. Overall, there should be no behavioral changes. If there are any stylistic issues, I will gladly adhere to them and adjust the PR accordingly. Thanks!

Co-authored-by: Basti Ortiz <39114273+Some-Dood@users.noreply.github.com>
2 years agoMerge #9828
bors[bot] [Wed, 11 Aug 2021 08:30:53 +0000 (08:30 +0000)]
Merge #9828

9828: Remove dependency on the system graphviz when rendering crate graph r=lnicola a=p32blo

This PR removes the need for having `graphviz` installed on the user system by using the `d3-graphviz` npm package.

The responsibility of rendering the svg output is moved to the extension while the rust side only handles the generation of the dot file.

This change also brings the following additional features:
- Allow zooming the view
- Ctrl+click to reset the zoom
- Adjust the color scheme to dark themes
- Works on any platform without installing graphviz locally

---

I’m not sure if this fits what you had in mind for the crates graph feature but I decided to submit it anyway to see if this is useful to anyone else.

A potential downside might be that it increases the extension size ( haven’t checked) but this feature already required the installation of graphviz on the user side, so the cost is just moved explicitly to the extension.

Feel free to make any suggestion or comments.

Co-authored-by: André Oliveira <p32blo@gmail.com>
2 years agowip enum record/tuple generation
Yoshua Wuyts [Tue, 10 Aug 2021 20:08:14 +0000 (22:08 +0200)]
wip enum record/tuple generation

2 years agogen PartialEq for basic enums
Yoshua Wuyts [Tue, 10 Aug 2021 19:05:23 +0000 (21:05 +0200)]
gen PartialEq for basic enums

2 years agogen PartialEq for structs
Yoshua Wuyts [Tue, 10 Aug 2021 17:49:06 +0000 (19:49 +0200)]
gen PartialEq for structs

2 years agoadd partial_eq gen tests
Yoshua Wuyts [Tue, 10 Aug 2021 17:48:50 +0000 (19:48 +0200)]
add partial_eq gen tests

2 years agoadd make::expr_op
Yoshua Wuyts [Tue, 10 Aug 2021 17:48:32 +0000 (19:48 +0200)]
add make::expr_op

2 years agoMerge #9849
bors[bot] [Tue, 10 Aug 2021 15:05:04 +0000 (15:05 +0000)]
Merge #9849

9849: internal: Refine functional update completion some more r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/9839
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRefine functional update completion some more
Lukas Wirth [Tue, 10 Aug 2021 15:03:38 +0000 (17:03 +0200)]
Refine functional update completion some more

2 years agoFix: revert strange usage of `?` operator
Basti Ortiz [Tue, 10 Aug 2021 14:44:15 +0000 (22:44 +0800)]
Fix: revert strange usage of `?` operator

2 years agoFix: prefer the usage of `for` loops over `fold`
Basti Ortiz [Tue, 10 Aug 2021 14:40:04 +0000 (22:40 +0800)]
Fix: prefer the usage of `for` loops over `fold`

2 years agoChore: add comments to explicitly express two-step check
Basti Ortiz [Tue, 10 Aug 2021 14:30:08 +0000 (22:30 +0800)]
Chore: add comments to explicitly express two-step check

See https://github.com/rust-analyzer/rust-analyzer/pull/9836#discussion_r685953381

2 years agoFix: revert complex conditional in `Directories::contains_file`
Basti Ortiz [Tue, 10 Aug 2021 14:25:43 +0000 (22:25 +0800)]
Fix: revert complex conditional in `Directories::contains_file`

This reverts commit 6d0336b2e41703254b31f5d9a1358eb7e15cee3f.

2 years agoUpdate 'package-lock.json'
André Oliveira [Tue, 10 Aug 2021 13:46:44 +0000 (13:46 +0000)]
Update 'package-lock.json'

2 years agoEmbed the scripts in the html template
André Oliveira [Tue, 10 Aug 2021 12:42:50 +0000 (12:42 +0000)]
Embed the scripts in the html template

2 years agoRemove unecessary joinPaths
André Oliveira [Tue, 10 Aug 2021 09:19:27 +0000 (09:19 +0000)]
Remove unecessary joinPaths

2 years agoInclude the needed node_modules files in the final extension bundle
André Oliveira [Tue, 10 Aug 2021 07:55:56 +0000 (07:55 +0000)]
Include the needed node_modules files in the final extension bundle

2 years agoFormatting issues
André Oliveira [Mon, 9 Aug 2021 17:45:42 +0000 (17:45 +0000)]
Formatting issues

2 years agoreplace let by const
André Oliveira [Sat, 7 Aug 2021 00:02:56 +0000 (00:02 +0000)]
replace let by const

2 years agoRemove debug logs
André Oliveira [Fri, 6 Aug 2021 23:52:33 +0000 (23:52 +0000)]
Remove debug logs

2 years agoReduce path handling code
André Oliveira [Fri, 6 Aug 2021 17:14:47 +0000 (17:14 +0000)]
Reduce path handling code

2 years agoAdd more features to the rendering
André Oliveira [Mon, 9 Aug 2021 07:01:42 +0000 (07:01 +0000)]
Add more features to the rendering

- Allow the zoom to go further than 10x
- Adapt css to dark and high constrast themess
- Use 'javascript/worker' for the wasm graphviz
- Add Ctrl + LeftMouseClick to reset zoom

2 years agoUse local node_modules to allow the graph to load offline
André Oliveira [Tue, 10 Aug 2021 13:35:37 +0000 (13:35 +0000)]
Use local node_modules to allow the graph to load offline

- Fix some warnings

2 years agoUse d3-graphviz for rendering crates graph on the extension side
André Oliveira [Tue, 10 Aug 2021 13:34:30 +0000 (13:34 +0000)]
Use d3-graphviz for rendering crates graph on the extension side

2 years agoMerge #9846
bors[bot] [Tue, 10 Aug 2021 13:18:09 +0000 (13:18 +0000)]
Merge #9846

9846: feat: Generate default trait fn impl when generating `Clone` r=Veykril a=yoshuawuyts

Implements a default trait function body when generating the `Clone` trait for a type. Thanks!

r? `@\veykril`

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2 years agoMerge #9845
bors[bot] [Tue, 10 Aug 2021 13:08:58 +0000 (13:08 +0000)]
Merge #9845

9845: fix: Do not drop `..Default::default()` completion when typing `..` r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/9839
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoDo not drop `..Default::default()` completion when typing `..`
Lukas Wirth [Tue, 10 Aug 2021 12:58:14 +0000 (14:58 +0200)]
Do not drop `..Default::default()` completion when typing `..`

2 years agogen clone for tuple enums
Yoshua Wuyts [Tue, 10 Aug 2021 13:07:13 +0000 (15:07 +0200)]
gen clone for tuple enums

2 years agogen clone for record enums
Yoshua Wuyts [Tue, 10 Aug 2021 12:43:20 +0000 (14:43 +0200)]
gen clone for record enums

2 years agoMerge #9842
bors[bot] [Tue, 10 Aug 2021 12:40:37 +0000 (12:40 +0000)]
Merge #9842

9842: fix: Substitute generic types in inline_call r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSubstitute generic types in inline_call
Lukas Wirth [Tue, 10 Aug 2021 12:39:56 +0000 (14:39 +0200)]
Substitute generic types in inline_call

2 years agoMerge #9841
bors[bot] [Tue, 10 Aug 2021 12:31:35 +0000 (12:31 +0000)]
Merge #9841

9841: internal: print total size of source code in analysis-stats r=matklad a=matklad

bors r+
đŸ¤–

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoUpdate crates/rust-analyzer/src/cli/analysis_stats.rs
Aleksey Kladov [Tue, 10 Aug 2021 12:31:12 +0000 (15:31 +0300)]
Update crates/rust-analyzer/src/cli/analysis_stats.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2 years agointernal: print total size of source code in analysis-stats
Aleksey Kladov [Tue, 10 Aug 2021 12:28:48 +0000 (15:28 +0300)]
internal: print total size of source code in analysis-stats

2 years agoMerge #9840
bors[bot] [Tue, 10 Aug 2021 11:57:20 +0000 (11:57 +0000)]
Merge #9840

9840: minor: reword a bit r=matklad a=matklad

bors r+
đŸ¤–

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: reword a bit
Aleksey Kladov [Tue, 10 Aug 2021 11:56:55 +0000 (14:56 +0300)]
minor: reword a bit

2 years agoadd clone generation for structs and bare enums
Yoshua Wuyts [Tue, 10 Aug 2021 11:55:26 +0000 (13:55 +0200)]
add clone generation for structs and bare enums

2 years agoMerge #9838
bors[bot] [Tue, 10 Aug 2021 11:34:47 +0000 (11:34 +0000)]
Merge #9838

9838: internal: document codebase stance on using functional combinators r=matklad a=matklad

bors r+
đŸ¤–

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: document codebase stance on using functional combinators
Aleksey Kladov [Tue, 10 Aug 2021 11:34:05 +0000 (14:34 +0300)]
internal: document codebase stance on using functional combinators

2 years agoMerge #9837
bors[bot] [Tue, 10 Aug 2021 11:24:08 +0000 (11:24 +0000)]
Merge #9837

9837: feat: Implement `bool_then_to_if` assist r=Veykril a=Veykril

Other half of https://github.com/rust-analyzer/rust-analyzer/issues/8413

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoAdd clone generation tests
Yoshua Wuyts [Tue, 10 Aug 2021 11:20:24 +0000 (13:20 +0200)]
Add clone generation tests

2 years agoImplement `bool_then_to_if` assist
Lukas Wirth [Tue, 10 Aug 2021 11:03:12 +0000 (13:03 +0200)]
Implement `bool_then_to_if` assist

2 years agoMerge #9835
bors[bot] [Tue, 10 Aug 2021 10:59:49 +0000 (10:59 +0000)]
Merge #9835

9835: feat: Generate default trait fn impl when generating `Hash`. r=Veykril a=yoshuawuyts

Implements a default trait function body when generating the `Hash` trait for a type. Thanks!

r? `@Veykril`

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2 years agoimpl gen hash for structs
Yoshua Wuyts [Tue, 10 Aug 2021 10:13:30 +0000 (12:13 +0200)]
impl gen hash for structs

2 years agoimpl gen hash for enums
Yoshua Wuyts [Tue, 10 Aug 2021 09:59:41 +0000 (11:59 +0200)]
impl gen hash for enums

2 years agoMerge #9830
bors[bot] [Tue, 10 Aug 2021 10:27:55 +0000 (10:27 +0000)]
Merge #9830

9830: Enable more assists to generate default trait body impls r=Veykril a=yoshuawuyts

Enable more assists to benefit from trait body generation. Follow-up to #9825 and #9814.

__edit:__ I'd like to move the existing tests to this new file too, but I'll do that in a follow-up PR.

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2 years agoimplement feedback from review
Yoshua Wuyts [Tue, 10 Aug 2021 10:21:48 +0000 (12:21 +0200)]
implement feedback from review

2 years agoRefactor: use iterator methods over `for` loops
Basti Ortiz [Tue, 10 Aug 2021 09:51:11 +0000 (17:51 +0800)]
Refactor: use iterator methods over `for` loops

2 years agoMerge #9834
bors[bot] [Tue, 10 Aug 2021 09:50:42 +0000 (09:50 +0000)]
Merge #9834

9834: internal: unify subcommand handling between ra and xtask r=matklad a=matklad

bors r+
đŸ¤–

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: unify subcommand handling between ra and xtask
Aleksey Kladov [Tue, 10 Aug 2021 09:49:55 +0000 (12:49 +0300)]
internal: unify subcommand handling between ra and xtask

2 years agointernal: prepare to use standard .run pattern for subcommands
Aleksey Kladov [Tue, 10 Aug 2021 09:25:47 +0000 (12:25 +0300)]
internal: prepare to use standard .run pattern for subcommands

2 years agoMerge #9832
bors[bot] [Tue, 10 Aug 2021 09:21:32 +0000 (09:21 +0000)]
Merge #9832

9832: vscode extension: use esbuild instead of rollup. r=matklad a=yaymukund

This shaves a couple seconds off our build & trims npm dependencies. I tested it using VSCode's "Install [Extension] from VSIX" option and it seems to work. Note that it changes the root of the package from `out/src/main â†’ out/main`.

Fell out of the discussion in #9179

Co-authored-by: Mukund Lakshman <yaymukund@gmail.com>
2 years agovscode extension: use esbuild instead of rollup.
Mukund Lakshman [Tue, 10 Aug 2021 06:56:34 +0000 (07:56 +0100)]
vscode extension: use esbuild instead of rollup.

2 years agoMerge #9833
bors[bot] [Tue, 10 Aug 2021 09:13:38 +0000 (09:13 +0000)]
Merge #9833

9833: [semantic-highlighting] functions that consume  are marked as HlMod::Consuming r=matklad a=jhgg

Does as the PR title says, functions that *consume* self, are marked as *consuming*.

Co-authored-by: Jake Heinz <jh@discordapp.com>
2 years agoRefactor: simplify logic for `Directories::contains_file`
Basti Ortiz [Tue, 10 Aug 2021 08:32:00 +0000 (16:32 +0800)]
Refactor: simplify logic for `Directories::contains_file`

The logic was simply inverted to accomodate for the short-circuiting `&&` operator.

2 years agoAdd trait codegen to `add_missing_impl_members` assist
Yoshua Wuyts [Mon, 9 Aug 2021 21:26:28 +0000 (23:26 +0200)]
Add trait codegen to `add_missing_impl_members` assist

2 years agoRefactor: use `filter_map` when iterating over stored IDs and
Basti Ortiz [Tue, 10 Aug 2021 07:56:16 +0000 (15:56 +0800)]
Refactor: use `filter_map` when iterating over stored IDs and

2 years agoChore: use short-circuiting for file ID getter
Basti Ortiz [Tue, 10 Aug 2021 07:43:51 +0000 (15:43 +0800)]
Chore: use short-circuiting for file ID getter

2 years ago[semantic-highlighting] functions that consume are marked as HlMod::Consuming
Jake Heinz [Tue, 10 Aug 2021 07:31:30 +0000 (07:31 +0000)]
[semantic-highlighting] functions that consume  are marked as HlMod::Consuming

2 years agomove trait body gen code to utils
Yoshua Wuyts [Mon, 9 Aug 2021 19:47:44 +0000 (21:47 +0200)]
move trait body gen code to utils

2 years agoMerge #9804
bors[bot] [Mon, 9 Aug 2021 17:09:13 +0000 (17:09 +0000)]
Merge #9804

9804: Generate method from call r=matklad a=mahdi-frms

Needs a bit of refactoring. Tests also should be added.

Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2 years agoMerge #9825
bors[bot] [Mon, 9 Aug 2021 16:59:10 +0000 (16:59 +0000)]
Merge #9825

9825: Generate default impl when converting #[derive(Default)] to manual impl r=Veykril a=yoshuawuyts

Similar to https://github.com/rust-analyzer/rust-analyzer/pull/9814, but for `#[derive(Default)]`. Thanks!

## Follow-up steps
I've added the tests inside `handlers/replace_derive_with_manual_impl.rs` again, but I'm planning a follow-up PR to extract these to `utils/` so we can share them between assists - and maybe even add another assist just for the purpose of testing these impls (e.g. `generate_default_trait_body`).

The step after _that_ is likely to fill out the remaining traits, so we can make it so whenever RA auto-completes a trait which also can be derived, we provide a default function body.

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2 years agorefactor method generation assist
mahdi-frms [Mon, 9 Aug 2021 16:07:07 +0000 (20:37 +0430)]
refactor method generation assist

2 years agomethod gen assist usable in all of expression
mahdi-frms [Mon, 9 Aug 2021 14:51:15 +0000 (19:21 +0430)]
method gen assist usable in all of expression

2 years agoadd test for method generation assist
mahdi-frms [Mon, 9 Aug 2021 14:25:10 +0000 (18:55 +0430)]
add test for method generation assist

2 years agoOne assist for function and method generation
mahdi-frms [Sun, 8 Aug 2021 13:14:05 +0000 (17:44 +0430)]
One assist for function and method generation

2 years agomethod generation assist: store owned ast nodes
mahdi-frms [Sun, 8 Aug 2021 12:51:34 +0000 (17:21 +0430)]
method generation assist: store owned ast nodes

2 years agogenerate method adds pub keyword
mahdi-frms [Sat, 7 Aug 2021 09:29:33 +0000 (13:59 +0430)]
generate method adds pub keyword

2 years agogenerate method assist uses existing impl blocks
mahdi-frms [Sat, 7 Aug 2021 06:59:49 +0000 (11:29 +0430)]
generate method assist uses existing impl blocks

2 years agorefactor: use single next space
mahdi-frms [Thu, 5 Aug 2021 12:18:51 +0000 (16:48 +0430)]
refactor: use single next space

2 years agorefactor: use single fn_args
mahdi-frms [Thu, 5 Aug 2021 12:07:00 +0000 (16:37 +0430)]
refactor: use single fn_args

2 years agogenerate method assist
mahdi-frms [Thu, 5 Aug 2021 09:30:08 +0000 (14:00 +0430)]
generate method assist

2 years agomove code around
Yoshua Wuyts [Mon, 9 Aug 2021 16:27:01 +0000 (18:27 +0200)]
move code around