1
1
use std:: ops:: ControlFlow ;
2
2
3
- use crate :: Opaque ;
3
+ use crate :: {
4
+ ty:: { BoundRegion , BoundRegionKind } ,
5
+ Opaque ,
6
+ } ;
4
7
5
8
use super :: ty:: {
6
9
Allocation , Binder , Const , ConstDef , ExistentialPredicate , FnSig , GenericArgKind , GenericArgs ,
@@ -15,6 +18,9 @@ pub trait Visitor: Sized {
15
18
fn visit_const ( & mut self , c : & Const ) -> ControlFlow < Self :: Break > {
16
19
c. super_visit ( self )
17
20
}
21
+ fn visit_reg ( & mut self , reg : & Region ) -> ControlFlow < Self :: Break > {
22
+ reg. super_visit ( self )
23
+ }
18
24
}
19
25
20
26
pub trait Visitable {
@@ -102,11 +108,38 @@ impl Visitable for GenericArgs {
102
108
}
103
109
104
110
impl 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
+ }
106
123
ControlFlow :: Continue ( ( ) )
107
124
}
108
125
}
109
126
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
+
110
143
impl Visitable for GenericArgKind {
111
144
fn super_visit < V : Visitor > ( & self , visitor : & mut V ) -> ControlFlow < V :: Break > {
112
145
match self {
0 commit comments