11use std:: ops:: ControlFlow ;
22
3- use crate :: Opaque ;
3+ use crate :: {
4+ ty:: { BoundRegion , BoundRegionKind } ,
5+ Opaque ,
6+ } ;
47
58use super :: ty:: {
69 Allocation , Binder , Const , ConstDef , ExistentialPredicate , FnSig , GenericArgKind , GenericArgs ,
@@ -15,6 +18,9 @@ pub trait Visitor: Sized {
1518 fn visit_const ( & mut self , c : & Const ) -> ControlFlow < Self :: Break > {
1619 c. super_visit ( self )
1720 }
21+ fn visit_reg ( & mut self , reg : & Region ) -> ControlFlow < Self :: Break > {
22+ reg. super_visit ( self )
23+ }
1824}
1925
2026pub trait Visitable {
@@ -102,11 +108,38 @@ impl Visitable for GenericArgs {
102108}
103109
104110impl Visitable for Region {
105- fn super_visit < V : Visitor > ( & self , _visitor : & mut V ) -> ControlFlow < V :: Break > {
111+ fn visit < V : Visitor > ( & self , visitor : & mut V ) -> ControlFlow < V :: Break > {
112+ visitor. visit_reg ( self )
113+ }
114+
115+ fn super_visit < V : Visitor > ( & self , visitor : & mut V ) -> ControlFlow < V :: Break > {
116+ match self . kind . clone ( ) {
117+ crate :: ty:: RegionKind :: ReEarlyBound ( _) => { }
118+ crate :: ty:: RegionKind :: ReLateBound ( _, bound_reg) => bound_reg. visit ( visitor) ?,
119+ crate :: ty:: RegionKind :: ReStatic => { }
120+ crate :: ty:: RegionKind :: RePlaceholder ( bound_reg) => bound_reg. bound . visit ( visitor) ?,
121+ crate :: ty:: RegionKind :: ReErased => { }
122+ }
106123 ControlFlow :: Continue ( ( ) )
107124 }
108125}
109126
127+ impl Visitable for BoundRegion {
128+ fn super_visit < V : Visitor > ( & self , visitor : & mut V ) -> ControlFlow < V :: Break > {
129+ self . kind . visit ( visitor)
130+ }
131+ }
132+
133+ impl Visitable for BoundRegionKind {
134+ fn super_visit < V : Visitor > ( & self , _visitor : & mut V ) -> ControlFlow < V :: Break > {
135+ match self {
136+ BoundRegionKind :: BrAnon => ControlFlow :: Continue ( ( ) ) ,
137+ BoundRegionKind :: BrNamed ( _, _) => ControlFlow :: Continue ( ( ) ) ,
138+ BoundRegionKind :: BrEnv => ControlFlow :: Continue ( ( ) ) ,
139+ }
140+ }
141+ }
142+
110143impl Visitable for GenericArgKind {
111144 fn super_visit < V : Visitor > ( & self , visitor : & mut V ) -> ControlFlow < V :: Break > {
112145 match self {
0 commit comments