chalk_ir/visit/
binder_impls.rs

1//! This module contains impls of `TypeVisitable` for those types that
2//! introduce binders.
3//!
4//! The more interesting impls of `TypeVisitable` remain in the `visit` module.
5
6use crate::interner::HasInterner;
7use crate::{
8    Binders, Canonical, ControlFlow, DebruijnIndex, FnPointer, Interner, TypeVisitable, TypeVisitor,
9};
10
11impl<I: Interner> TypeVisitable<I> for FnPointer<I> {
12    fn visit_with<B>(
13        &self,
14        visitor: &mut dyn TypeVisitor<I, BreakTy = B>,
15        outer_binder: DebruijnIndex,
16    ) -> ControlFlow<B> {
17        self.substitution
18            .visit_with(visitor, outer_binder.shifted_in())
19    }
20}
21
22impl<T, I: Interner> TypeVisitable<I> for Binders<T>
23where
24    T: HasInterner + TypeVisitable<I>,
25{
26    fn visit_with<B>(
27        &self,
28        visitor: &mut dyn TypeVisitor<I, BreakTy = B>,
29        outer_binder: DebruijnIndex,
30    ) -> ControlFlow<B> {
31        self.value.visit_with(visitor, outer_binder.shifted_in())
32    }
33}
34
35impl<I, T> TypeVisitable<I> for Canonical<T>
36where
37    I: Interner,
38    T: HasInterner<Interner = I> + TypeVisitable<I>,
39{
40    fn visit_with<B>(
41        &self,
42        visitor: &mut dyn TypeVisitor<I, BreakTy = B>,
43        outer_binder: DebruijnIndex,
44    ) -> ControlFlow<B> {
45        self.value.visit_with(visitor, outer_binder.shifted_in())
46    }
47}