Merge pull request #20683 from regexident/inference-result-types-iter

Expose iterators over an inference result's types
This commit is contained in:
Chayim Refael Friedman 2025-09-24 17:12:33 +00:00 committed by GitHub
commit 993db83afd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -632,6 +632,26 @@ impl InferenceResult {
pub fn binding_mode(&self, id: PatId) -> Option<BindingMode> { pub fn binding_mode(&self, id: PatId) -> Option<BindingMode> {
self.binding_modes.get(id).copied() 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 { impl Index<ExprId> for InferenceResult {