From 7e9abceee79e950294d8e500ea773655af00e32e Mon Sep 17 00:00:00 2001 From: Vincent Esche Date: Wed, 17 Sep 2025 21:19:53 +0200 Subject: [PATCH] Expose iterators over an inference result's types (This re-introduces a reduced access to a couple of previously public fields on `InferenceResult`) --- crates/hir-ty/src/infer.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index 3ece62ec35b6..b5e9aece364c 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -632,6 +632,26 @@ impl InferenceResult { pub fn binding_mode(&self, id: PatId) -> Option { 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 { + 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 { + 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 { + 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 { + self.type_of_rpit.iter() + } } impl Index for InferenceResult {