@@ -4,17 +4,20 @@ use crate::Opaque;
4
4
5
5
use super :: ty:: {
6
6
Allocation , Binder , Const , ConstDef , ConstantKind , ExistentialPredicate , FnSig , GenericArgKind ,
7
- GenericArgs , Promoted , RigidTy , TermKind , Ty , TyKind , UnevaluatedConst ,
7
+ GenericArgs , Promoted , Region , RigidTy , TermKind , Ty , TyKind , UnevaluatedConst ,
8
8
} ;
9
9
10
10
pub trait Folder : Sized {
11
11
type Break ;
12
- fn visit_ty ( & mut self , ty : & Ty ) -> ControlFlow < Self :: Break , Ty > {
12
+ fn fold_ty ( & mut self , ty : & Ty ) -> ControlFlow < Self :: Break , Ty > {
13
13
ty. super_fold ( self )
14
14
}
15
15
fn fold_const ( & mut self , c : & Const ) -> ControlFlow < Self :: Break , Const > {
16
16
c. super_fold ( self )
17
17
}
18
+ fn fold_reg ( & mut self , reg : & Region ) -> ControlFlow < Self :: Break , Region > {
19
+ reg. super_fold ( self )
20
+ }
18
21
}
19
22
20
23
pub trait Foldable : Sized + Clone {
@@ -26,7 +29,7 @@ pub trait Foldable: Sized + Clone {
26
29
27
30
impl Foldable for Ty {
28
31
fn fold < V : Folder > ( & self , folder : & mut V ) -> ControlFlow < V :: Break , Self > {
29
- folder. visit_ty ( self )
32
+ folder. fold_ty ( self )
30
33
}
31
34
fn super_fold < V : Folder > ( & self , folder : & mut V ) -> ControlFlow < V :: Break , Self > {
32
35
let mut kind = self . kind ( ) ;
@@ -106,6 +109,15 @@ impl Foldable for GenericArgs {
106
109
}
107
110
}
108
111
112
+ impl Foldable for Region {
113
+ fn fold < V : Folder > ( & self , folder : & mut V ) -> ControlFlow < V :: Break , Self > {
114
+ folder. fold_reg ( self )
115
+ }
116
+ fn super_fold < V : Folder > ( & self , _: & mut V ) -> ControlFlow < V :: Break , Self > {
117
+ ControlFlow :: Continue ( self . clone ( ) )
118
+ }
119
+ }
120
+
109
121
impl Foldable for GenericArgKind {
110
122
fn super_fold < V : Folder > ( & self , folder : & mut V ) -> ControlFlow < V :: Break , Self > {
111
123
let mut this = self . clone ( ) ;
@@ -136,7 +148,10 @@ impl Foldable for RigidTy {
136
148
}
137
149
RigidTy :: Slice ( inner) => * inner = inner. fold ( folder) ?,
138
150
RigidTy :: RawPtr ( ty, _) => * ty = ty. fold ( folder) ?,
139
- RigidTy :: Ref ( _, ty, _) => * ty = ty. fold ( folder) ?,
151
+ RigidTy :: Ref ( reg, ty, _) => {
152
+ * reg = reg. fold ( folder) ?;
153
+ * ty = ty. fold ( folder) ?
154
+ }
140
155
RigidTy :: FnDef ( _, args) => * args = args. fold ( folder) ?,
141
156
RigidTy :: FnPtr ( sig) => * sig = sig. fold ( folder) ?,
142
157
RigidTy :: Closure ( _, args) => * args = args. fold ( folder) ?,
@@ -214,7 +229,7 @@ pub enum Never {}
214
229
impl Folder for GenericArgs {
215
230
type Break = Never ;
216
231
217
- fn visit_ty ( & mut self , ty : & Ty ) -> ControlFlow < Self :: Break , Ty > {
232
+ fn fold_ty ( & mut self , ty : & Ty ) -> ControlFlow < Self :: Break , Ty > {
218
233
ControlFlow :: Continue ( match ty. kind ( ) {
219
234
TyKind :: Param ( p) => self [ p] ,
220
235
_ => * ty,
0 commit comments