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`.
rust-analyzer is a modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.
Quick Start
https://rust-analyzer.github.io/manual.html#installation
Documentation
If you want to contribute to rust-analyzer or are just curious about how things work under the hood, check the ./docs/dev folder.
If you want to use rust-analyzer's language server with your editor of choice, check the manual folder. It also contains some tips & tricks to help you be more productive when using rust-analyzer.
Security and Privacy
See the corresponding sections of the manual.
Communication
For usage and troubleshooting requests, please use "IDEs and Editors" category of the Rust forum:
https://users.rust-lang.org/c/ide/14
For questions about development and implementation, join rust-analyzer working group on Zulip:
https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer
Quick Links
- Website: https://rust-analyzer.github.io/
- Metrics: https://rust-analyzer.github.io/metrics/
- API docs: https://rust-lang.github.io/rust-analyzer/ide/
- Changelog: https://rust-analyzer.github.io/thisweek
License
rust-analyzer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.