Commit graph

364 commits

Author SHA1 Message Date
bors[bot]
5664a2b0b3
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>
2021-08-08 22:30:37 +00:00
Lukas Wirth
3b7c713af3 Implement if_to_bool_then assist 2021-08-08 17:56:34 +02:00
Yoshua Wuyts
4b7ae9fedc generate Debug for enums 2021-08-08 16:26:25 +02:00
Yoshua Wuyts
fd7236c791 debug for record field structs 2021-08-08 16:26:25 +02:00
Lukas Wirth
c4a119f433 Simplify 2021-08-07 22:16:15 +02:00
bors[bot]
80f522091a
Merge #9790
9790: fix: extract_type_alias extracts generics correctly r=Veykril a=Veykril

Fixes #8335
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-05 00:54:49 +00:00
Lukas Wirth
b6d574642d extract_type_alias extracts generics correctly 2021-08-05 02:54:06 +02:00
Jade
775670e32c Split the test 2021-08-04 03:01:48 -07:00
Jade
b90ed92a5c Support exclusive_range_pattern
Fix #9779
2021-08-03 21:36:29 -07:00
Jade
e3a67ccec6 tree-wide: fix rustdoc warnings, add some links 2021-08-03 21:34:20 -07:00
Lukas Wirth
1edbaa29f9 Wrap inner tail expressions in MissingOkOrSomeInTailExpr 2021-07-31 20:00:09 +02:00
bors[bot]
0cf28cedef
Merge #9740
9740: feat: `add_explicit_type` is applicable for closure parameters r=Veykril a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8886
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-31 12:05:41 +00:00
Lukas Wirth
778e6e8ba8 add_explicit_type is applicable for closure parameters 2021-07-31 14:04:34 +02:00
Laurențiu Nicola
90e05ba57e Bump deps 2021-07-31 11:25:03 +03:00
bors[bot]
1f817833e7
Merge #9727
9727: internal: Simplify extract_function assist r=Veykril a=Veykril

also fixes #7839(blocked on #9728)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-30 14:56:50 +00:00
bors[bot]
0a3ac7a96c
Merge #9728
9728: fix: Attach comma token to MATCH_ARM instead of MATCH_ARM_LIST r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-30 14:11:37 +00:00
Lukas Wirth
82c1e61887 Fix assists assuming comma belonging to MATCH_ARM_LIST 2021-07-30 16:01:26 +02:00
Lukas Wirth
f04cff102f Simplify 2021-07-30 13:12:52 +02:00
Lukas Wirth
4de447b293 Attach comma token to MATCH_ARM instead of MATCH_ARM_LIST 2021-07-29 23:02:52 +02:00
Lukas Wirth
b21f66fce3 Simplify extract_function assist 2021-07-29 22:07:56 +02:00
Lukas Wirth
b537cb186e Use more strictly typed syntax nodes for analysis in extract_function assist 2021-07-29 17:26:37 +02:00
Alexander Gonzalez
e57ad5456c fix: Typos 2021-07-27 18:31:21 -04:00
Lukas Wirth
f43cd562bc Fix generic_arg not parsing opt_generic_arg_list properly in arg lists 2021-07-26 15:21:19 +02:00
Lukas Wirth
dfdf6fd9f8 Fix some more basic clippy lints 2021-07-21 20:52:08 +02:00
Lukas Wirth
f6cb42fdb8 Restrict completions inside visibility modifiers 2021-07-20 18:37:52 +02:00
bors[bot]
ea105f9396
Merge #9619
9619: Support GATs for associated type arg parsing r=Veykril a=Veykril

Fixes #9602

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-18 09:10:56 +00:00
Lukas Wirth
e7aa37c20a Support GATs for associated type arg parsing 2021-07-18 11:08:43 +02:00
Aleksey Kladov
15f11dce4a feat: improve parser error recovery for function parameters 2021-07-17 22:41:04 +03:00
bors[bot]
2e52d6ea93
Merge #9557
9557: fix: Respect coercions in `inline_call` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 17:25:16 +00:00
Lukas Wirth
9e1eb77f6b Respect coercions in inline_call 2021-07-10 19:24:49 +02:00
Laurențiu Nicola
861f1e2a86 Bump rustc_lexer a little 2021-07-10 18:57:59 +03:00
vi_mi
57f119b5fa fix: Adding async keyword when await is present in generate_function assist 2021-07-09 20:04:55 +05:30
Lukas Wirth
2579dc6d82 Update inline_call assist doc example 2021-07-05 14:24:25 +02:00
bors[bot]
2bc4f9e371
Merge #9474
9474: fix: Inline parameters in `inline_call` if possible r=Veykril a=Veykril

Fixes #9491

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-05 11:50:18 +00:00
Lukas Wirth
ea02d27a1e Fixup emitted whitespace in most cases 2021-07-05 13:44:42 +02:00
Aleksey Kladov
86720f2953 minor: drop dummy authors field 2021-07-05 14:19:41 +03:00
Aleksey Kladov
c4d2671767 minor: untangle complex condition 2021-07-04 17:32:59 +03:00
Aleksey Kladov
c2704bebc1 minor: better error message 2021-07-04 11:20:31 +03:00
bors[bot]
336194c09b
Merge #9476
9476: internal: overhaul codegen r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-03 19:26:04 +00:00
Aleksey Kladov
58d2ece88a internal: overhaul code generation
* Keep codegen adjacent to the relevant crates.
* Remove codgen deps from xtask, speeding-up from-source installation.

This regresses the release process a bit, as it now needs to run the
tests (and, by extension, compile the code).
2021-07-03 22:11:03 +03:00
Lukas Wirth
d308f17a21 Inline parameters in inline_call if possible 2021-07-03 20:05:54 +02:00
Lukas Wirth
14e18bfa38 Merge the inline function/method assists into inline_call 2021-07-03 18:07:03 +02:00
Lukas Wirth
688398febc feat: Implement inline_method assist 2021-07-03 01:33:34 +02:00
Lukas Wirth
251f0c6090 replace_match_with_if_let works on more binary matches 2021-07-02 21:05:10 +02:00
bors[bot]
d18cfd4467
Merge #9458
9458: minor: Remove make::match_arm_with_guard r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-01 23:47:38 +00:00
Lukas Wirth
071ac48b6c Remove make::match_arm_with_guard 2021-07-02 01:44:54 +02:00
bors[bot]
cd3d633850
Merge #9455
9455: feat: Handle not let if expressions in replace_if_let_with_match r=Veykril a=Veykril

Transforms bare `if cond {}` into `_ if cond` guard patterns in the match as long as at least one `if let` is in the if chain, otherwise the assist wont be applicable.

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-01 23:00:50 +00:00
Lukas Wirth
8967856d78 Handle not let if expressions in replace_if_let_with_match 2021-07-02 00:58:56 +02:00
bors[bot]
c8c4d73648
Merge #9437
9437: fix: Don't classify paths inside attribute TokenTrees r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-30 19:52:03 +00:00
Lukas Wirth
04f1104179 Don't classify NameRef paths inside attribute TokenTrees 2021-06-30 21:51:28 +02:00