]> git.proxmox.com Git - rustc.git/blob - vendor/chalk-ir/src/visit/binder_impls.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / vendor / chalk-ir / src / 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
6 use crate::interner::HasInterner;
7 use crate::{
8 Binders, Canonical, ControlFlow, DebruijnIndex, FnPointer, Interner, TypeVisitable, TypeVisitor,
9 };
10
11 impl<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
22 impl<T, I: Interner> TypeVisitable<I> for Binders<T>
23 where
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
35 impl<I, T> TypeVisitable<I> for Canonical<T>
36 where
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 }