rust/crates
bors eeceba7480 Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril
Support generic function in `generate_function` assist

Part of #3639

This PR adds support for generic function generation in `generate_function` assist. Now the assist looks for generic parameters and trait bounds in scope, filters out irrelevant ones, and generates new function with them.

See `fn_generic_params()` for the outline of the procedure, and see comments on `filter_unnecessary_bounds()` for criteria for filtering. I think it's good criteria for most cases, but I'm open to opinions and suggestions.

The diff is pretty big, but it should run in linear time w.r.t. the number of nodes we operate on and should be fast enough.

Some notes:
- When we generate function in an existing impl, generic parameters may cause name conflict. While we can detect the conflict and rename conflicting params, I didn't find it worthwhile mainly because it's really easy to resolve on IDE: use Rename functionality.
- I've implemented graph structure myself, because we don't have graph library as a dependency and we only need the simplest one.
  - Although `petgraph` is in our dependency graph and I was initially looking to use it, we don't actually depend on it AFAICT since it's only used in chalk's specialization graph handling, which we don't use. I'd be happy to replace my implementation with `petgraph` if it's okay to use it though.
- There are some caveats that I consider out of scope of this PR. See FIXME notes on added tests.
2023-02-02 09:06:22 +00:00
..
base-db Make tt generic over the span data 2023-01-31 14:58:16 +01:00
cfg Make tt generic over the span data 2023-01-31 14:58:16 +01:00
flycheck Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril 2023-01-17 10:29:27 +00:00
hir Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril 2023-02-02 09:06:22 +00:00
hir-def Make tt generic over the span data 2023-01-31 14:58:16 +01:00
hir-expand Auto merge of #14036 - Veykril:write-method-resolution, r=Veykril 2023-02-01 10:23:33 +00:00
hir-ty Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril 2023-02-02 09:06:22 +00:00
ide Auto merge of #14058 - gftea:master, r=Veykril 2023-02-01 20:00:19 +00:00
ide-assists Treat scope info retrieval failure as assist failure 2023-02-02 17:47:11 +09:00
ide-completion Set "current" edition to 2021 2023-01-31 10:51:43 +00:00
ide-db Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril 2023-02-02 09:06:22 +00:00
ide-diagnostics Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril 2023-01-17 10:29:27 +00:00
ide-ssr Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril 2023-01-17 10:29:27 +00:00
intern Bump once_cell 2023-01-21 08:48:46 +02:00
limit Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
mbe Make tt generic over the span data 2023-01-31 14:58:16 +01:00
parser Parse const_closures syntax. 2023-01-19 15:40:07 +01:00
paths Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
proc-macro-api Bump zip 2023-02-01 19:24:32 +02:00
proc-macro-srv Make tt generic over the span data 2023-01-31 14:58:16 +01:00
proc-macro-srv-cli Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril 2023-01-17 10:29:27 +00:00
proc-macro-test Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril 2023-01-17 10:29:27 +00:00
profile Bump zip 2023-02-01 19:24:32 +02:00
project-model Set "current" edition to 2021 2023-01-31 10:51:43 +00:00
rust-analyzer Make tt generic over the span data 2023-01-31 14:58:16 +01:00
sourcegen Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
stdx Make tt generic over the span data 2023-01-31 14:58:16 +01:00
syntax Support generic function in generate_function assist 2023-01-31 21:05:25 +09:00
test-utils Auto merge of #14036 - Veykril:write-method-resolution, r=Veykril 2023-02-01 10:23:33 +00:00
text-edit Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
toolchain Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
tt Make tt generic over the span data 2023-01-31 14:58:16 +01:00
vfs fix: Fix process-changes not deduplicating changes correctly 2023-01-25 15:01:15 +01:00
vfs-notify Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril 2023-01-17 10:29:27 +00:00