rust/crates/hir/src
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
..
semantics Split out hir-def attribute handling parts into hir-expand 2023-01-09 19:29:28 +01:00
attrs.rs Inline all format arguments where possible 2022-12-24 14:36:10 -05:00
db.rs
diagnostics.rs Diagnose private assoc item accesses 2023-01-01 13:24:48 +01:00
display.rs Replace SmolStr usage with lang item enum for lang items 2023-01-21 17:55:45 +01:00
from_id.rs Implemented basic enum const eval 2022-09-12 20:19:13 +01:00
has_source.rs fix(ide-db): correct single-file module rename 2022-05-28 15:07:22 +03:00
lib.rs Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril 2023-02-02 09:06:22 +00:00
semantics.rs Minor refactoring 2023-01-31 21:05:04 +09:00
source_analyzer.rs Record method resolution for call expressions 2023-01-27 11:06:41 +01:00
symbols.rs Cleaned up code 2022-09-12 20:19:49 +01:00