Commit Graph

18929 Commits

Author SHA1 Message Date
bors[bot]
b641a66078
Merge #9905
9905: internal: optimize compile time r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-15 10:26:59 +00:00
Aleksey Kladov
92da7e9ffa internal: optimize compile time
cargo llvm-lines shows that path_to_error bloats the code. I don't think
I've needed this functionality recently, seems that we've fixed most of
the serialization problems. So let's just remove it. Should be easy to
add back if we ever need it, and it does make sense to keep the
`from_json` function around.
2021-08-15 13:24:37 +03:00
bors[bot]
933a4dc3a6
Merge #9902
9902: minor: move functionality to a better place r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 17:43:52 +00:00
Aleksey Kladov
3c49a9f079 minor: move functionality to a better place 2021-08-14 20:43:28 +03:00
bors[bot]
182a2b8e72
Merge #9901
9901: internal: remove dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 17:30:13 +00:00
Aleksey Kladov
78c7940f5c internal: remove dead code 2021-08-14 20:29:46 +03:00
bors[bot]
1e0d20366f
Merge #9900
9900: internal: remove one more usage of old editing API. r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 17:17:51 +00:00
Aleksey Kladov
e300f58d2c internal: remove one more usage of old editing API. 2021-08-14 20:17:16 +03:00
bors[bot]
01de9021cd
Merge #9899
9899: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-14 17:10:04 +00:00
Lukas Wirth
2e733b1a3e Simplify 2021-08-14 19:09:36 +02:00
bors[bot]
4be69436dd
Merge #9897
9897: internal: remove old editing API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 16:46:19 +00:00
Aleksey Kladov
a26b1c3923 internal: remove old editing API 2021-08-14 19:45:47 +03:00
bors[bot]
d7374ab882
Merge #9896
9896: internal: Only complete type annotations for patterns in function params r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-14 16:19:14 +00:00
Lukas Wirth
bf918046fa Only complete type annotations for patterns in function params 2021-08-14 18:18:32 +02:00
bors[bot]
5a60e9106b
Merge #9895
9895: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-14 16:07:09 +00:00
Lukas Wirth
894a09b749 Simplify 2021-08-14 18:02:51 +02:00
bors[bot]
5d7ff6efe3
Merge #9894
9894: internal: use standard test style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 15:59:47 +00:00
Aleksey Kladov
c3bbeb947c internal: use standard test style 2021-08-14 18:53:21 +03:00
bors[bot]
d07f4e4c35
Merge #9893
9893: fix: Don't use uncached syntax nodes in `generate_function` for sema lookups r=Veykril a=Veykril

Fixes the crash in the comment here https://github.com/rust-analyzer/rust-analyzer/issues/9382#issuecomment-896101298
Couldn't make out a repro test for this unfortunately
still not idea about the original issue

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-14 15:52:48 +00:00
Lukas Wirth
37ad9cb2a5 Don't use non cache syntaxnodes in generate_function for lookups 2021-08-14 17:51:11 +02:00
bors[bot]
c1a7169bf0
Merge #9892
9892: internal: remove a remnant of old editing infra r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 15:40:20 +00:00
Aleksey Kladov
a78decc466 internal: make assist naming consistent 2021-08-14 18:39:56 +03:00
Aleksey Kladov
dc17b35e62 internal: remove a remnant of old editing infra 2021-08-14 18:24:42 +03:00
bors[bot]
bd2219bd99
Merge #9890
9890: internal: refactor binary operator handling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-14 15:11:17 +00:00
Aleksey Kladov
90357a9090 internal: merge hir::BinaryOp and ast::BinOp 2021-08-14 18:10:01 +03:00
Aleksey Kladov
fe4f059450 internal: prepare to merge hir::BinaryOp and ast::BinOp 2021-08-14 17:07:51 +03:00
Aleksey Kladov
6df00f8495 internal: make naming consistent 2021-08-14 17:01:28 +03:00
Aleksey Kladov
faa420fc32 internal: prepare a dedicated module for all operators 2021-08-14 16:58:46 +03:00
bors[bot]
01b589b082
Merge #9889
9889: Update manual.adoc: added juCi++ section r=lnicola a=eidheim



Co-authored-by: Ole Christian Eidheim <eidheim@gmail.com>
2021-08-14 13:41:00 +00:00
Aleksey Kladov
beca92b245 internal: make invert binary op more robust
Previously, we only inverted comparison operators (< and the like) if
the type implemented Ord. This doesn't make sense: if `<` works, then
`>=` will work as well!

Extra semantic checks greatly reduce robustness and predictability of
the assist, it's better to keep things simple.
2021-08-14 16:40:00 +03:00
Ole Christian Eidheim
06da68303d
Update manual.adoc: added juCi++ section 2021-08-14 12:47:58 +02:00
bors[bot]
49dbb74a0b
Merge #9882
9882: fix: Don't call deprecated `compile` regex method r=lnicola a=lnicola

Fixes #9872

It looks like `compile` expects to be called like `RegExp.compile("foo", "m")`, so calling `.compile()` on an existing regex replaces it with an empty one.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-08-14 07:39:46 +00:00
bors[bot]
c5ddc35a45
Merge #9886
9886: feat: type inference for if-let guards r=jonas-schievink a=jonas-schievink

This turned out fairly simple

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-08-13 22:12:58 +00:00
Jonas Schievink
4757679b9a feat: type inference for if-let guards 2021-08-14 00:09:30 +02:00
bors[bot]
0d5408195e
Merge #9884
9884: cargo update r=kjeremy a=kjeremy

Remove paste-impl and proc-macro-hack.

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2021-08-13 15:24:35 +00:00
Jeremy Kolb
ddf23abfef cargo update 2021-08-13 11:08:24 -04:00
bors[bot]
43af7920af
Merge #9871
9871: Jump to generated func r=mahdi-frms a=rylev

Worked on this with `@yoshuawuyts.`

We thought we ran into an issue with the `generate_function` assist where the code was not being generated in a certain situations. However, it wasn't actually a bug just a very confusing implementation where the cursor is not moved to the newly generated function. This happened when the return type was successfully inferred (and not unit). The function would be generated, but selection would not be changed.

This can be very confusing: If the function is generated somewhat far from where the assist is being invoked, the user never sees that the code was generated (nor are they given the chance to actually implement the function body). 

This PR makes it so that the cursor is _always_ moved to somewhere in the newly generated function. In addition, if we can infer unit as the type, then we do not still generate `-> ()` as the return type. Instead, we simply omit the return type.

This means the selection will move to either one of two places:
* A generated `-> ()` return type when we cannot successfully infer the return type.
* The `todo!()` body when we can successfully infer the return type.

Co-authored-by: Ryan Levick <me@ryanlevick.com>
2021-08-13 11:19:16 +00:00
Laurențiu Nicola
743b016313 Don't call deprecated compile regex method 2021-08-13 14:16:33 +03:00
Ryan Levick
1cc43ab7f4 Add documentation on how whether a generated return type should be focused or not 2021-08-13 11:46:08 +02:00
bors[bot]
c00ccdeb52
Merge #9879
9879: feat: Support `if let` match guards r=jonas-schievink a=jonas-schievink

Adds support for parsing and computing bindings for `if let` match guards (https://github.com/rust-lang/rust/issues/51114). Type inference support is still missing, but shouldn't be hard to add in a follow-up PR.

Closes https://github.com/rust-analyzer/rust-analyzer/issues/9876

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-08-12 22:28:04 +00:00
Jonas Schievink
d568e7686a Support if let match guards 2021-08-13 00:25:14 +02:00
bors[bot]
4466e07fd7
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>
2021-08-12 19:45:06 +00:00
Jonas Schievink
6f579c4862 Always add implicit proc_macro dependency 2021-08-12 21:42: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
bors[bot]
c619cb12d7
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>
2021-08-12 12:11:09 +00: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