Skip to content

Commit 7e9abce

Browse files
committed
Expose iterators over an inference result's types
(This re-introduces a reduced access to a couple of previously public fields on `InferenceResult`)
1 parent f6cf303 commit 7e9abce

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)