about summary refs log tree commit diff
path: root/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-02 09:06:22 +0000
committerbors <bors@rust-lang.org>2023-02-02 09:06:22 +0000
commiteeceba748053cc365a55c3c73798186ceec09991 (patch)
tree9fd82d6d25542ca16c9a6a107a7f98a847002513 /tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff
parentccd142c6163c992dfb482b85bbddbb7b3370c9c8 (diff)
parent493cabbde7f5838cbc0e1ccebc15dd6a5c82c1c5 (diff)
downloadrust-eeceba748053cc365a55c3c73798186ceec09991.tar.gz
rust-eeceba748053cc365a55c3c73798186ceec09991.zip
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.
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff')
0 files changed, 0 insertions, 0 deletions