rust-analyzer/crates
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
..
base_db Complete editable private items 2021-07-23 19:57:16 +02:00
cfg internal: remove useless helpers 2021-08-09 15:58:21 +03:00
flycheck internal: a bit more of cwd safety for flycheck 2021-07-17 18:13:35 +03:00
hir Merge #9807 2021-08-12 17:55:29 +00:00
hir_def Support if let match guards 2021-08-13 00:25:14 +02:00
hir_expand fix: avoid pathological macro expansions 2021-08-09 16:15:02 +03:00
hir_ty Support if let match guards 2021-08-13 00:25:14 +02:00
ide Merge #9807 2021-08-12 17:55:29 +00:00
ide_assists Merge #9871 2021-08-13 11:19:16 +00:00
ide_completion Fill out expected type for functional update syntax completion 2021-08-11 18:12:44 +02:00
ide_db Substitute generic types in inline_call 2021-08-10 14:39:56 +02:00
ide_diagnostics Merge #9810 2021-08-08 10:35:00 +00:00
ide_ssr fix: avoid pathological macro expansions 2021-08-09 16:15:02 +03:00
limit internal: add API to check what are the max limits in practice 2021-07-31 18:26:43 +03:00
mbe internal: remove useless helpers 2021-08-09 15:58:21 +03:00
parser Support if let match guards 2021-08-13 00:25:14 +02:00
paths Fix AbsPath::ends_with 2021-07-18 10:25:14 +03:00
proc_macro_api Replace useless types 2021-07-31 14:29:15 +02:00
proc_macro_srv Copy the proc_macro crate for the 1.56 ABI 2021-08-07 16:34:59 +01:00
proc_macro_test cargo_metadata 0.14 2021-07-09 11:01:55 -04:00
profile internal: make non-zero times stand out in profile 2021-07-31 16:22:03 +03:00
project_model Always add implicit proc_macro dependency 2021-08-12 21:42:14 +02:00
rust-analyzer Formatting issues 2021-08-10 13:43:57 +00:00
sourcegen minor: make sure that project_root works correctly 2021-07-13 15:02:29 +03:00
stdx Remove proc macro management thread 2021-07-08 16:43:39 +02:00
syntax Support if let match guards 2021-08-13 00:25:14 +02:00
test_utils Show type actions on ranged type hover 2021-08-11 13:52:57 +02:00
text_edit minor: as per code-styple, add invariant comment 2021-08-09 13:13:02 +03:00
toolchain minor: drop dummy authors field 2021-07-05 14:19:41 +03:00
tt minor: drop dummy authors field 2021-07-05 14:19:41 +03:00
vfs internal: document that ascription is preferred to a turbo fish 2021-08-11 14:16:15 +03:00
vfs-notify Downgrade notify and use RecommendedWatcher 2021-08-03 14:33:37 +03:00