]>
git.lizzy.rs Git - rust.git/log
Lukas Wirth [Sat, 14 Aug 2021 15:42:06 +0000 (17:42 +0200)]
Don't use non cache syntaxnodes in generate_function for lookups
bors[bot] [Sat, 14 Aug 2021 15:40:20 +0000 (15:40 +0000)]
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>
Aleksey Kladov [Sat, 14 Aug 2021 15:28:38 +0000 (18:28 +0300)]
internal: make assist naming consistent
Aleksey Kladov [Sat, 14 Aug 2021 15:24:42 +0000 (18:24 +0300)]
internal: remove a remnant of old editing infra
bors[bot] [Sat, 14 Aug 2021 15:11:17 +0000 (15:11 +0000)]
Merge #9890
9890: internal: refactor binary operator handling r=matklad a=matklad
bors r+
đŸ¤–
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Aleksey Kladov [Sat, 14 Aug 2021 15:08:31 +0000 (18:08 +0300)]
internal: merge hir::BinaryOp and ast::BinOp
Aleksey Kladov [Sat, 14 Aug 2021 14:07:51 +0000 (17:07 +0300)]
internal: prepare to merge hir::BinaryOp and ast::BinOp
Aleksey Kladov [Sat, 14 Aug 2021 14:01:28 +0000 (17:01 +0300)]
internal: make naming consistent
Aleksey Kladov [Sat, 14 Aug 2021 13:58:46 +0000 (16:58 +0300)]
internal: prepare a dedicated module for all operators
bors[bot] [Sat, 14 Aug 2021 13:41:00 +0000 (13:41 +0000)]
Merge #9889
9889: Update manual.adoc: added juCi++ section r=lnicola a=eidheim
Co-authored-by: Ole Christian Eidheim <eidheim@gmail.com>
Aleksey Kladov [Sat, 14 Aug 2021 13:40:00 +0000 (16:40 +0300)]
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.
Ole Christian Eidheim [Sat, 14 Aug 2021 10:47:58 +0000 (12:47 +0200)]
Update manual.adoc: added juCi++ section
bors[bot] [Sat, 14 Aug 2021 07:39:46 +0000 (07:39 +0000)]
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>
bors[bot] [Fri, 13 Aug 2021 22:12:58 +0000 (22:12 +0000)]
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>
Jonas Schievink [Fri, 13 Aug 2021 22:09:30 +0000 (00:09 +0200)]
feat: type inference for if-let guards
bors[bot] [Fri, 13 Aug 2021 15:24:35 +0000 (15:24 +0000)]
Merge #9884
9884: cargo update r=kjeremy a=kjeremy
Remove paste-impl and proc-macro-hack.
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
Jeremy Kolb [Fri, 13 Aug 2021 15:08:24 +0000 (11:08 -0400)]
cargo update
bors[bot] [Fri, 13 Aug 2021 11:19:16 +0000 (11:19 +0000)]
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>
Laurențiu Nicola [Fri, 13 Aug 2021 11:16:33 +0000 (14:16 +0300)]
Don't call deprecated compile regex method
Ryan Levick [Fri, 13 Aug 2021 09:44:29 +0000 (11:44 +0200)]
Add documentation on how whether a generated return type should be focused or not
bors[bot] [Thu, 12 Aug 2021 22:28:04 +0000 (22:28 +0000)]
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>
Jonas Schievink [Thu, 12 Aug 2021 22:21:42 +0000 (00:21 +0200)]
Support `if let` match guards
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>
Jonas Schievink [Thu, 12 Aug 2021 19:42:14 +0000 (21:42 +0200)]
Always add implicit `proc_macro` dependency
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>
Dawer [Thu, 12 Aug 2021 14:31:00 +0000 (19:31 +0500)]
Clean up
Ryan Levick [Thu, 12 Aug 2021 14:05:32 +0000 (16:05 +0200)]
Factor out return type handling for both function and method
Ryan Levick [Thu, 12 Aug 2021 12:56:39 +0000 (14:56 +0200)]
Always fall back to focusing on generated function body
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>
Ryan Levick [Thu, 12 Aug 2021 11:59:08 +0000 (13:59 +0200)]
Use term on label for generating method impl
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>
Yoshua Wuyts [Thu, 12 Aug 2021 10:17:09 +0000 (12:17 +0200)]
add `make::ext::path_from_idents`
Yoshua Wuyts [Thu, 12 Aug 2021 09:50:01 +0000 (11:50 +0200)]
implement feedback from review
Yoshua Wuyts [Wed, 11 Aug 2021 21:30:00 +0000 (23:30 +0200)]
rm remaining todo comment
Yoshua Wuyts [Wed, 11 Aug 2021 18:33:13 +0000 (20:33 +0200)]
improve codegen
Yoshua Wuyts [Wed, 11 Aug 2021 18:04:05 +0000 (20:04 +0200)]
finishing touches
Yoshua Wuyts [Wed, 11 Aug 2021 18:01:19 +0000 (20:01 +0200)]
gen partialeq for tuple enums
Yoshua Wuyts [Wed, 11 Aug 2021 17:40:47 +0000 (19:40 +0200)]
dedup PartialEq for Record enums
Dawer [Wed, 11 Aug 2021 17:09:32 +0000 (22:09 +0500)]
Accept ambiguous unsize coercion only if it has definite guidance.
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>
Lukas Wirth [Wed, 11 Aug 2021 16:05:39 +0000 (18:05 +0200)]
Fill out expected type for functional update syntax completion
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>
Lukas Wirth [Wed, 11 Aug 2021 15:52:09 +0000 (17:52 +0200)]
extract_variable handles selection ranges better
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>
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>
Lukas Wirth [Wed, 11 Aug 2021 15:09:51 +0000 (17:09 +0200)]
Fix extract_function tagging params as mut unnecessarily
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>
Lukas Wirth [Wed, 11 Aug 2021 11:39:36 +0000 (13:39 +0200)]
Show type actions on ranged type hover
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>
Aleksey Kladov [Wed, 11 Aug 2021 11:16:15 +0000 (14:16 +0300)]
internal: document that ascription is preferred to a turbo fish
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>
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>
Yoshua Wuyts [Tue, 10 Aug 2021 20:08:14 +0000 (22:08 +0200)]
wip enum record/tuple generation
Yoshua Wuyts [Tue, 10 Aug 2021 19:05:23 +0000 (21:05 +0200)]
gen PartialEq for basic enums
Yoshua Wuyts [Tue, 10 Aug 2021 17:49:06 +0000 (19:49 +0200)]
gen PartialEq for structs
Yoshua Wuyts [Tue, 10 Aug 2021 17:48:50 +0000 (19:48 +0200)]
add partial_eq gen tests
Yoshua Wuyts [Tue, 10 Aug 2021 17:48:32 +0000 (19:48 +0200)]
add make::expr_op
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>
Lukas Wirth [Tue, 10 Aug 2021 15:03:38 +0000 (17:03 +0200)]
Refine functional update completion some more
Basti Ortiz [Tue, 10 Aug 2021 14:44:15 +0000 (22:44 +0800)]
Fix: revert strange usage of `?` operator
Basti Ortiz [Tue, 10 Aug 2021 14:40:04 +0000 (22:40 +0800)]
Fix: prefer the usage of `for` loops over `fold`
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
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 .
André Oliveira [Tue, 10 Aug 2021 13:46:44 +0000 (13:46 +0000)]
Update 'package-lock.json'
André Oliveira [Tue, 10 Aug 2021 12:42:50 +0000 (12:42 +0000)]
Embed the scripts in the html template
André Oliveira [Tue, 10 Aug 2021 09:19:27 +0000 (09:19 +0000)]
Remove unecessary joinPaths
André Oliveira [Tue, 10 Aug 2021 07:55:56 +0000 (07:55 +0000)]
Include the needed node_modules files in the final extension bundle
André Oliveira [Mon, 9 Aug 2021 17:45:42 +0000 (17:45 +0000)]
Formatting issues
André Oliveira [Sat, 7 Aug 2021 00:02:56 +0000 (00:02 +0000)]
replace let by const
André Oliveira [Fri, 6 Aug 2021 23:52:33 +0000 (23:52 +0000)]
Remove debug logs
André Oliveira [Fri, 6 Aug 2021 17:14:47 +0000 (17:14 +0000)]
Reduce path handling code
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
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
André Oliveira [Tue, 10 Aug 2021 13:34:30 +0000 (13:34 +0000)]
Use d3-graphviz for rendering crates graph on the extension side
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>
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>
Lukas Wirth [Tue, 10 Aug 2021 12:58:14 +0000 (14:58 +0200)]
Do not drop `..Default::default()` completion when typing `..`
Yoshua Wuyts [Tue, 10 Aug 2021 13:07:13 +0000 (15:07 +0200)]
gen clone for tuple enums
Yoshua Wuyts [Tue, 10 Aug 2021 12:43:20 +0000 (14:43 +0200)]
gen clone for record enums
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>
Lukas Wirth [Tue, 10 Aug 2021 12:39:56 +0000 (14:39 +0200)]
Substitute generic types in inline_call
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>
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>
Aleksey Kladov [Tue, 10 Aug 2021 12:28:48 +0000 (15:28 +0300)]
internal: print total size of source code in analysis-stats
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>
Aleksey Kladov [Tue, 10 Aug 2021 11:56:55 +0000 (14:56 +0300)]
minor: reword a bit
Yoshua Wuyts [Tue, 10 Aug 2021 11:55:26 +0000 (13:55 +0200)]
add clone generation for structs and bare enums
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>
Aleksey Kladov [Tue, 10 Aug 2021 11:34:05 +0000 (14:34 +0300)]
internal: document codebase stance on using functional combinators
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>
Yoshua Wuyts [Tue, 10 Aug 2021 11:20:24 +0000 (13:20 +0200)]
Add clone generation tests
Lukas Wirth [Tue, 10 Aug 2021 11:03:12 +0000 (13:03 +0200)]
Implement `bool_then_to_if` assist
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>
Yoshua Wuyts [Tue, 10 Aug 2021 10:13:30 +0000 (12:13 +0200)]
impl gen hash for structs
Yoshua Wuyts [Tue, 10 Aug 2021 09:59:41 +0000 (11:59 +0200)]
impl gen hash for enums
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>
Yoshua Wuyts [Tue, 10 Aug 2021 10:21:48 +0000 (12:21 +0200)]
implement feedback from review
Basti Ortiz [Tue, 10 Aug 2021 09:51:11 +0000 (17:51 +0800)]
Refactor: use iterator methods over `for` loops
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>
Aleksey Kladov [Tue, 10 Aug 2021 09:49:55 +0000 (12:49 +0300)]
internal: unify subcommand handling between ra and xtask