rust-analyzer/crates
bors 073b3253c1 Auto merge of #12556 - DorianListens:dscheidt/generic-extract, r=Veykril
fix: Support generics in extract_function assist

This change attempts to resolve issue #7636: Extract into Function does not
create a generic function with constraints when extracting generic code.

In `FunctionBody::analyze_container`, we now traverse the `ancestors` in search
of `AnyHasGenericParams`, and attach any `GenericParamList`s and `WhereClause`s
we find to the `ContainerInfo`.

Later, in `format_function`, we collect all the `GenericParam`s and
`WherePred`s from the container, and filter them to keep only types matching
`TypeParam`s used within the newly extracted function body or param list. We
can then include the new `GenericParamList` and `WhereClause` in the new
function definition.

This change only impacts `TypeParam`s. `LifetimeParam`s and `ConstParam`s are
out of scope for this change.

I've never contributed to this project before, but I did try to follow the style guide. I believe that this change represents an improvement over the status quo, but I think it's also fair to argue that it doesn't fully "fix" the linked issue. I'm totally open to merging this as is, or going further to try to make a more complete solution. Also: if there are other unit or integration tests I should add, please let me know where to look!
2022-07-14 14:29:37 +00:00
..
base-db Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
cfg internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
flycheck Bump cargo_metadata 2022-07-03 10:09:35 +03:00
hir fix: Support generics in extract_function assist 2022-07-13 14:54:10 -05:00
hir-def Implement ignore and index metavar expression 2022-07-11 18:31:42 +02:00
hir-expand Auto merge of #12691 - Veykril:proc-macro-diag, r=Veykril 2022-07-14 14:21:16 +00:00
hir-ty Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
ide Fix typos 2022-07-11 21:42:05 +08:00
ide-assists Auto merge of #12556 - DorianListens:dscheidt/generic-extract, r=Veykril 2022-07-14 14:29:37 +00:00
ide-completion Auto merge of #12735 - feniljain:fix-completions, r=feniljain 2022-07-14 11:53:29 +00:00
ide-db Auto merge of #12691 - Veykril:proc-macro-diag, r=Veykril 2022-07-14 14:21:16 +00:00
ide-diagnostics Auto merge of #12691 - Veykril:proc-macro-diag, r=Veykril 2022-07-14 14:21:16 +00:00
ide-ssr internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
limit Use compare_exchange_weak in limit::Limit::check 2022-01-28 18:19:35 +03:00
mbe Implement ignore and index metavar expression 2022-07-11 18:31:42 +02:00
parser Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
paths Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
proc-macro-api Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
proc-macro-srv Update 1.63 proc macro ABI to match rustc 2022-07-12 15:19:31 +02:00
proc-macro-test Bump cargo_metadata 2022-07-03 10:09:35 +03:00
profile Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
project-model Fix rustcSource -> rustc_source 2022-07-11 16:50:20 +09:00
rust-analyzer Fix obsolete enableRangeFormatting config 2022-07-11 16:52:35 +09:00
sourcegen Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
stdx Polish 2022-06-15 18:35:48 +02:00
syntax Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
test-utils internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
text-edit style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
toolchain Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
tt internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
vfs Bump indexmap 2022-07-03 10:09:35 +03:00
vfs-notify Bump crossbeam-channel 2022-07-03 09:56:58 +03:00