]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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

2 years agoMerge #9827
bors[bot] [Mon, 9 Aug 2021 16:26:24 +0000 (16:26 +0000)]
Merge #9827

9827: internal: remove client-side support for latest requests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: remove client-side support for latest requests
Aleksey Kladov [Mon, 9 Aug 2021 16:24:43 +0000 (19:24 +0300)]
internal: remove client-side support for latest requests

Companion for #9826

2 years agoMerge #9826
bors[bot] [Mon, 9 Aug 2021 16:04:03 +0000 (16:04 +0000)]
Merge #9826

9826: internal: drop latest requests tracking r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: drop latest requests tracking
Aleksey Kladov [Mon, 9 Aug 2021 15:56:19 +0000 (18:56 +0300)]
internal: drop latest requests tracking

From the dawn of time, when dinosaurs roamed the and we didn't have
hierarchical profiling, there was the `latest_requests` infra we used to
track the time of ten last requests.

Today, no one is actually using it and, what's more, it itself became
pretty useless -- LSP grew way more chatty, and 10 requests don't really
paint any kind of picture.

Personally, it's been years since I last looked at latest requests in
the status output.

So, let's remove a tiny bit of state from the big ball of complexity
that is `GlobalState` and `main_loop`!

2 years agoAdd gen default for tuple structs
Yoshua Wuyts [Mon, 9 Aug 2021 15:28:06 +0000 (17:28 +0200)]
Add gen default for tuple structs

2 years agoAdd default body when implementing Default by hand
Yoshua Wuyts [Mon, 9 Aug 2021 15:12:18 +0000 (17:12 +0200)]
Add default body when implementing Default by hand

2 years agoMerge #9823
bors[bot] [Mon, 9 Aug 2021 13:16:43 +0000 (13:16 +0000)]
Merge #9823

9823: fix: avoid pathological macro expansions  r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agofix: avoid pathological macro expansions
Aleksey Kladov [Mon, 9 Aug 2021 13:06:49 +0000 (16:06 +0300)]
fix: avoid pathological macro expansions

Today, rust-analyzer (and rustc, and bat, and IntelliJ) fail badly on
some kinds of maliciously constructed code, like a deep sequence of
nested parenthesis.

"Who writes 100k nested parenthesis" you'd ask?

Well, in a language with macros, a run-away macro expansion might do
that (see the added tests)! Such expansion can be broad, rather than
deep, so it bypasses recursion check at the macro-expansion layer, but
triggers deep recursion in parser.

In the ideal world, the parser would just handle deeply nested structs
gracefully. We'll get there some day, but at the moment, let's try to be
simple, and just avoid expanding macros with unbalanced parenthesis in
the first place.

closes #9358

2 years agointernal: remove useless helpers
Aleksey Kladov [Mon, 9 Aug 2021 12:41:19 +0000 (15:41 +0300)]
internal: remove useless helpers

We generally avoid "syntax only" helper wrappers, which don't do much:
they make code easier to write, but harder to read. They also make
investigations harder, as "find_usages" needs to be invoked both for the
wrapped and unwrapped APIs

2 years agoMerge #9821
bors[bot] [Mon, 9 Aug 2021 11:06:58 +0000 (11:06 +0000)]
Merge #9821

9821: minor: Fix typo in reference modifier description r=lnicola a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoFix typo in reference modifier description
Laurențiu Nicola [Mon, 9 Aug 2021 11:06:14 +0000 (14:06 +0300)]
Fix typo in reference modifier description

2 years agoMerge #9735
bors[bot] [Mon, 9 Aug 2021 10:21:14 +0000 (10:21 +0000)]
Merge #9735

9735: Add assist to sort members alphabetically. r=matklad a=vsrs

Supports traits, impls, structs, unions and enums (including inner struct variants). Does not support modules yet.

```rust
en┃um Animal {
  Dog(String, f64),
  Cat { weight: f64, name: String },
}
```
->
```rust
enum Animal {
  Cat { weight: f64, name: String },
  Dog(String, f64),
}
```
---
```rust
enum Animal {
  Dog(String, f64),
  Cat {┃ weight: f64, name: String },
}
```
->
```rust
enum Animal {
  Dog(String, f64),
  Cat { name: String, weight: f64 },
}
```
---
More samples in docs https://github.com/vsrs/rust-analyzer/blob/0b7835619a3ec7fdc5c11e6ab001ad452314a3f2/crates/ide_assists/src/handlers/sort_items.rs#L12-L83.

Relates #6110

Co-authored-by: vsrs <vit@conrlab.com>
2 years agoMerge #9820
bors[bot] [Mon, 9 Aug 2021 10:13:23 +0000 (10:13 +0000)]
Merge #9820

9820: minor: as per code-styple, add invariant comment r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: as per code-styple, add invariant comment
Aleksey Kladov [Mon, 9 Aug 2021 10:13:02 +0000 (13:13 +0300)]
minor: as per code-styple, add invariant comment

2 years agoMerge #9814
bors[bot] [Sun, 8 Aug 2021 22:30:37 +0000 (22:30 +0000)]
Merge #9814

9814: Generate default impl when converting `#[derive(Debug)]` to manual impl r=yoshuawuyts a=yoshuawuyts

This patch makes it so when you convert `#[derive(Debug)]` to a manual impl, a default body is provided that's equivalent to the original output of `#[derive(Debug)]`. This should make it drastically easier to write custom `Debug` impls, especially when all you want to do is quickly omit a single field which is `!Debug`.

This is implemented for enums, record structs, tuple structs, empty structs - and it sets us up to implement variations on this in the future for other traits (like `PartialEq` and `Hash`).

Thanks!

## Codegen diff
This is the difference in codegen for record structs with this patch:
```diff
struct Foo {
    bar: String,
}

impl fmt::Debug for Foo {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        todo!();
+        f.debug_struct("Foo").field("bar", &self.bar).finish()
    }
}
```

Co-authored-by: Irina Shestak <shestak.irina@gmail.com>
Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Co-authored-by: Yoshua Wuyts <yoshuawuyts+github@gmail.com>
2 years agoRemove unwraps
Yoshua Wuyts [Sun, 8 Aug 2021 22:29:38 +0000 (00:29 +0200)]
Remove unwraps

2 years agoUpdate crates/test_utils/src/minicore.rs
Yoshua Wuyts [Sun, 8 Aug 2021 22:00:09 +0000 (00:00 +0200)]
Update crates/test_utils/src/minicore.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #9816
bors[bot] [Sun, 8 Aug 2021 18:42:19 +0000 (18:42 +0000)]
Merge #9816

9816: feat: Implement if_to_bool_then assist r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUse minicore
Yoshua Wuyts [Sun, 8 Aug 2021 16:58:42 +0000 (18:58 +0200)]
Use minicore

2 years agoexclude files from tidy check
Yoshua Wuyts [Sun, 8 Aug 2021 16:44:54 +0000 (18:44 +0200)]
exclude files from tidy check

2 years agoMerge #9817
bors[bot] [Sun, 8 Aug 2021 16:07:09 +0000 (16:07 +0000)]
Merge #9817

9817: fix: Increase chalk overflow depth r=flodiebold a=lnicola

This makes the experience better for people using `tonic`, see https://github.com/rust-analyzer/rust-analyzer/issues/7817.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoImplement if_to_bool_then assist
Lukas Wirth [Sun, 8 Aug 2021 15:12:08 +0000 (17:12 +0200)]
Implement if_to_bool_then assist

2 years agoIncrease chalk overflow depth
Laurențiu Nicola [Sun, 8 Aug 2021 15:40:28 +0000 (18:40 +0300)]
Increase chalk overflow depth

2 years agouse make::name_ref
Yoshua Wuyts [Sun, 8 Aug 2021 14:31:28 +0000 (16:31 +0200)]
use make::name_ref

2 years agoUpdate replace_derive_with_manual_impl.rs
Yoshua Wuyts [Sun, 8 Aug 2021 14:24:14 +0000 (16:24 +0200)]
Update replace_derive_with_manual_impl.rs