rust/crates/hir/src
bors 6b250a22c4 Auto merge of #16687 - kilpkonn:master, r=Veykril
feat: Add "make tuple" tactic to term search

Follow up to https://github.com/rust-lang/rust-analyzer/pull/16092

Now term search also supports tuples.
```rust
let a: i32 = 1;
let b: f64 = 0.0;
let c: (i32, (f64, i32)) = todo!(); // Finds (a, (b, a))
```
In addition to new tactic that handles tuples I changed how the generics are handled.
Previously it tried all possible options from types we had in scope but now it only tries useful ones that help us directly towards the goal or at least towards calling some other function.
This changes O(2^n) to O(n^2) where n is amount of rounds which in practice allows using types that take generics for multiple rounds (previously limited to 1). Average case that also used to be exponential is now roughly linear.
This means that deeply nested generics also work.
````rust
// Finds all valid combos, including `Some(Some(Some(...)))`
let a: Option<Option<Option<bool>>> = todo!();
````

_Note that although the complexity is smaller allowing more types with generics the search overall slows down considerably. I hope it's fine tho as the autocomplete is disabled by default and for code actions it's not super slow. Might have to tweak the depth hyper parameter tho_

This resulted in a huge increase of results found (benchmarks on `ripgrep` crate):
Before
````
Tail Expr syntactic hits: 149/1692 (8%)
Tail Exprs found: 749/1692 (44%)
Term search avg time: 18ms
```
After
```
Tail Expr syntactic hits: 291/1692 (17%)
Tail Exprs found: 1253/1692 (74%)
Term search avg time: 139ms
````

Most changes are local to term search except some tuple related stuff on `hir::Type`.
2024-02-27 09:41:14 +00:00
..
semantics fix: Fix modules in blocks not resolving in ide layer 2024-02-26 14:54:47 +01:00
term_search Add make_tuple tactic 2024-02-26 20:17:09 +02:00
attrs.rs clippy: Enable self_named_constructors rule 2024-02-09 22:31:21 +09:00
db.rs internal: Make data queries transparent over their diagnostics variant 2024-01-16 10:47:54 +01:00
diagnostics.rs fix: Don't panic on synthetic syntax in inference diagnostics 2024-02-26 17:46:03 +01:00
display.rs fix: Fix tuple structs not rendering visibility in their fields 2024-02-08 10:05:28 +01:00
from_id.rs Eagerly lower enum variants in CrateDefMap construction 2024-01-15 10:24:14 +01:00
has_source.rs Eagerly lower enum variants in CrateDefMap construction 2024-01-15 10:24:14 +01:00
lib.rs Auto merge of #16687 - kilpkonn:master, r=Veykril 2024-02-27 09:41:14 +00:00
semantics.rs fix: Fix completions panicking with certain macro setups 2024-02-27 09:35:57 +01:00
source_analyzer.rs redundant_pattern_matching 2024-01-19 17:31:01 +01:00
symbols.rs Eagerly lower enum variants in CrateDefMap construction 2024-01-15 10:24:14 +01:00
term_search.rs Add make_tuple tactic 2024-02-26 20:17:09 +02:00