Jonas Schievink
d568e7686a
Support if let
match guards
2021-08-13 00:25:14 +02:00
bors[bot]
baf1494374
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>
2021-08-12 17:55:29 +00:00
Dawer
6c366ade00
Clean up
2021-08-12 21:20:28 +05:00
Ryan Levick
a5c46e5a88
Factor out return type handling for both function and method
2021-08-12 16:05:32 +02:00
Ryan Levick
0834e05045
Always fall back to focusing on generated function body
2021-08-12 14:56:39 +02:00
Ryan Levick
e8de34b6b3
Use term on label for generating method impl
2021-08-12 14:01:15 +02:00
bors[bot]
1376ece497
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>
2021-08-12 10:18:02 +00:00
Yoshua Wuyts
97ec6a27ec
add make::ext::path_from_idents
2021-08-12 12:17:09 +02:00
Yoshua Wuyts
df19895ba6
implement feedback from review
2021-08-12 11:50:01 +02:00
Yoshua Wuyts
8ed24029c1
rm remaining todo comment
2021-08-11 23:30:00 +02:00
Yoshua Wuyts
2fff019b6b
improve codegen
2021-08-11 20:33:13 +02:00
Yoshua Wuyts
6c4a94b03a
finishing touches
2021-08-11 20:04:05 +02:00
Yoshua Wuyts
c4e10c81b9
gen partialeq for tuple enums
2021-08-11 20:01:19 +02:00
Yoshua Wuyts
741e27b414
dedup PartialEq for Record enums
2021-08-11 19:40:47 +02:00
Lukas Wirth
6045059916
extract_variable handles selection ranges better
2021-08-11 17:52:09 +02:00
Yoshua Wuyts
fc17eb482d
gen PartialEq for Record enums
...
Co-Authored-By: Ryan Levick <rylev@users.noreply.github.com>
2021-08-11 17:15:12 +02:00
bors[bot]
f438dbb100
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>
2021-08-11 15:10:26 +00:00
Lukas Wirth
6d960ab032
Fix extract_function tagging params as mut unnecessarily
2021-08-11 17:09:51 +02:00
Aleksey Kladov
629c68e80d
internal: document that ascription is preferred to a turbo fish
2021-08-11 14:16:15 +03:00
Yoshua Wuyts
1cf7af7032
wip enum record/tuple generation
2021-08-10 22:08:14 +02:00
Yoshua Wuyts
65ce87cad8
gen PartialEq for basic enums
2021-08-10 21:05:23 +02:00
Yoshua Wuyts
f8a64c044a
gen PartialEq for structs
2021-08-10 19:49:06 +02:00
Yoshua Wuyts
3cad2c4feb
add partial_eq gen tests
2021-08-10 19:48:50 +02:00
bors[bot]
e1dcec0e02
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>
2021-08-10 13:18:09 +00:00
Yoshua Wuyts
2f866974d9
gen clone for tuple enums
2021-08-10 15:07:13 +02:00
Yoshua Wuyts
e0adb39de3
gen clone for record enums
2021-08-10 14:43:20 +02:00
Lukas Wirth
7e6eb67f0d
Substitute generic types in inline_call
2021-08-10 14:39:56 +02:00
Yoshua Wuyts
7ddc26aea1
add clone generation for structs and bare enums
2021-08-10 13:55:26 +02:00
Yoshua Wuyts
7d7a50daf7
Add clone generation tests
2021-08-10 13:20:24 +02:00
Lukas Wirth
b7d7dd6163
Implement bool_then_to_if
assist
2021-08-10 13:17:45 +02:00
Yoshua Wuyts
4b5139e8a5
impl gen hash for structs
2021-08-10 12:37:10 +02:00
Yoshua Wuyts
ec2535e9ce
impl gen hash for enums
2021-08-10 12:37:10 +02:00
Yoshua Wuyts
326890753c
implement feedback from review
2021-08-10 12:21:48 +02:00
Yoshua Wuyts
d6b788a9ee
Add trait codegen to add_missing_impl_members
assist
2021-08-10 10:27:52 +02:00
Yoshua Wuyts
4d2e25a034
move trait body gen code to utils
2021-08-09 21:47:44 +02:00
bors[bot]
8e4fb4f518
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>
2021-08-09 17:09:13 +00:00
bors[bot]
63427afb69
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>
2021-08-09 16:59:10 +00:00
mahdi-frms
05a789c09d
refactor method generation assist
2021-08-09 21:06:24 +04:30
mahdi-frms
9217f6dcf7
method gen assist usable in all of expression
2021-08-09 21:06:24 +04:30
mahdi-frms
311dc5b04f
add test for method generation assist
2021-08-09 21:06:24 +04:30
mahdi-frms
3c31f3831d
One assist for function and method generation
2021-08-09 21:06:24 +04:30
mahdi-frms
02f5b5e0e2
method generation assist: store owned ast nodes
2021-08-09 21:06:24 +04:30
mahdi-frms
6240b2dae2
generate method adds pub keyword
2021-08-09 21:06:24 +04:30
mahdi-frms
d38f36e5af
generate method assist uses existing impl blocks
2021-08-09 21:06:24 +04:30
mahdi-frms
99570f32d8
refactor: use single next space
2021-08-09 21:06:24 +04:30
mahdi-frms
b777e498fe
refactor: use single fn_args
2021-08-09 21:06:24 +04:30
mahdi-frms
9ca73528ee
generate method assist
2021-08-09 21:06:24 +04:30
Yoshua Wuyts
13749e782e
move code around
2021-08-09 18:27:01 +02:00
Yoshua Wuyts
457eede795
Add gen default for tuple structs
2021-08-09 17:40:50 +02:00
Yoshua Wuyts
423860cd7e
Add default body when implementing Default by hand
2021-08-09 17:12:18 +02:00