diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2025-09-24 17:12:33 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-24 17:12:33 +0000 |
| commit | 871261ac1479cb9a780419bd1bea6ba429bb5912 (patch) | |
| tree | f1cbf9ac4e88147a6d9c8b2c82f645e9c21e153a | |
| parent | affd5c0df21e5cb77c48b240bd9fc02ec9352de5 (diff) | |
| parent | a025cacc600fe1848db29cdaf199ac2d33f83181 (diff) | |
Merge pull request #20683 from regexident/inference-result-types-iter
Expose iterators over an inference result's types
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-ty/src/infer.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs index 0a095ea6445..fd10f923987 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs @@ -632,6 +632,26 @@ impl InferenceResult { pub fn binding_mode(&self, id: PatId) -> Option<BindingMode> { self.binding_modes.get(id).copied() } + + // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. + pub fn expression_types(&self) -> impl Iterator<Item = (ExprId, &Ty)> { + self.type_of_expr.iter() + } + + // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. + pub fn pattern_types(&self) -> impl Iterator<Item = (PatId, &Ty)> { + self.type_of_pat.iter() + } + + // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. + pub fn binding_types(&self) -> impl Iterator<Item = (BindingId, &Ty)> { + self.type_of_binding.iter() + } + + // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. + pub fn return_position_impl_trait_types(&self) -> impl Iterator<Item = (ImplTraitIdx, &Ty)> { + self.type_of_rpit.iter() + } } impl Index<ExprId> for InferenceResult { |
