Skip to content

Commit 993db83

Browse files
Merge pull request #20683 from regexident/inference-result-types-iter
Expose iterators over an inference result's types
2 parents 4d4a1dd + 7e9abce commit 993db83

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/hir-ty/src/infer.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,26 @@ impl InferenceResult {
632632
pub fn binding_mode(&self, id: PatId) -> Option<BindingMode> {
633633
self.binding_modes.get(id).copied()
634634
}
635+
636+
// This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please.
637+
pub fn expression_types(&self) -> impl Iterator<Item = (ExprId, &Ty)> {
638+
self.type_of_expr.iter()
639+
}
640+
641+
// This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please.
642+
pub fn pattern_types(&self) -> impl Iterator<Item = (PatId, &Ty)> {
643+
self.type_of_pat.iter()
644+
}
645+
646+
// This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please.
647+
pub fn binding_types(&self) -> impl Iterator<Item = (BindingId, &Ty)> {
648+
self.type_of_binding.iter()
649+
}
650+
651+
// This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please.
652+
pub fn return_position_impl_trait_types(&self) -> impl Iterator<Item = (ImplTraitIdx, &Ty)> {
653+
self.type_of_rpit.iter()
654+
}
635655
}
636656

637657
impl Index<ExprId> for InferenceResult {

0 commit comments

Comments
 (0)