14
14
//! instance of a "folder" (a type which implements `TypeFolder`). Then
15
15
//! the setup is intended to be:
16
16
//!
17
- //! T.fold_with(F) --calls--> F.fold_T(T) --calls--> T.fold_subitems_with (F)
17
+ //! T.fold_with(F) --calls--> F.fold_T(T) --calls--> T.super_fold_with (F)
18
18
//!
19
19
//! This way, when you define a new folder F, you can override
20
- //! `fold_T()` to customize the behavior, and invoke `T.fold_subitems_with ()`
20
+ //! `fold_T()` to customize the behavior, and invoke `T.super_fold_with ()`
21
21
//! to get the original behavior. Meanwhile, to actually fold
22
22
//! something, you can just write `T.fold_with(F)`, which is
23
23
//! convenient. (Note that `fold_with` will also transparently handle
24
24
//! things like a `Vec<T>` where T is foldable and so on.)
25
25
//!
26
26
//! In this ideal setup, the only function that actually *does*
27
- //! anything is `T.fold_subitems_with ()`, which traverses the type `T`.
28
- //! Moreover, `T.fold_subitems_with ()` should only ever call `T.fold_with()`.
27
+ //! anything is `T.super_fold_with ()`, which traverses the type `T`.
28
+ //! Moreover, `T.super_fold_with ()` should only ever call `T.fold_with()`.
29
29
//!
30
30
//! In some cases, we follow a degenerate pattern where we do not have
31
31
//! a `fold_T` method. Instead, `T.fold_with` traverses the structure directly.
35
35
//! proper thing.
36
36
//!
37
37
//! A `TypeFoldable` T can also be visited by a `TypeVisitor` V using similar setup:
38
- //! T.visit_with(V) --calls--> V.visit_T(T) --calls--> T.visit_subitems_with (V).
38
+ //! T.visit_with(V) --calls--> V.visit_T(T) --calls--> T.super_visit_with (V).
39
39
//! These methods return true to indicate that the visitor has found what it is looking for
40
40
//! and does not need to visit anything else.
41
41
@@ -50,14 +50,14 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
50
50
/// The TypeFoldable trait is implemented for every type that can be folded.
51
51
/// Basically, every type that has a corresponding method in TypeFolder.
52
52
pub trait TypeFoldable < ' tcx > : fmt:: Debug + Clone {
53
- fn fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self ;
54
- fn fold_subitems_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
55
- self . fold_with ( folder)
53
+ fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self ;
54
+ fn fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
55
+ self . super_fold_with ( folder)
56
56
}
57
57
58
- fn visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool ;
59
- fn visit_subitems_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
60
- self . visit_with ( visitor)
58
+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool ;
59
+ fn visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
60
+ self . super_visit_with ( visitor)
61
61
}
62
62
63
63
fn has_regions_escaping_depth ( & self , depth : u32 ) -> bool {
@@ -131,64 +131,64 @@ pub trait TypeFolder<'tcx> : Sized {
131
131
where T : TypeFoldable < ' tcx >
132
132
{
133
133
// FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
134
- t. fold_subitems_with ( self )
134
+ t. super_fold_with ( self )
135
135
}
136
136
137
137
fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
138
- t. fold_subitems_with ( self )
138
+ t. super_fold_with ( self )
139
139
}
140
140
141
141
fn fold_mt ( & mut self , t : & ty:: TypeAndMut < ' tcx > ) -> ty:: TypeAndMut < ' tcx > {
142
- t. fold_subitems_with ( self )
142
+ t. super_fold_with ( self )
143
143
}
144
144
145
145
fn fold_trait_ref ( & mut self , t : & ty:: TraitRef < ' tcx > ) -> ty:: TraitRef < ' tcx > {
146
- t. fold_subitems_with ( self )
146
+ t. super_fold_with ( self )
147
147
}
148
148
149
149
fn fold_substs ( & mut self ,
150
150
substs : & subst:: Substs < ' tcx > )
151
151
-> subst:: Substs < ' tcx > {
152
- substs. fold_subitems_with ( self )
152
+ substs. super_fold_with ( self )
153
153
}
154
154
155
155
fn fold_fn_sig ( & mut self ,
156
156
sig : & ty:: FnSig < ' tcx > )
157
157
-> ty:: FnSig < ' tcx > {
158
- sig. fold_subitems_with ( self )
158
+ sig. super_fold_with ( self )
159
159
}
160
160
161
161
fn fold_output ( & mut self ,
162
162
output : & ty:: FnOutput < ' tcx > )
163
163
-> ty:: FnOutput < ' tcx > {
164
- output. fold_subitems_with ( self )
164
+ output. super_fold_with ( self )
165
165
}
166
166
167
167
fn fold_bare_fn_ty ( & mut self ,
168
168
fty : & ty:: BareFnTy < ' tcx > )
169
169
-> ty:: BareFnTy < ' tcx >
170
170
{
171
- fty. fold_subitems_with ( self )
171
+ fty. super_fold_with ( self )
172
172
}
173
173
174
174
fn fold_closure_ty ( & mut self ,
175
175
fty : & ty:: ClosureTy < ' tcx > )
176
176
-> ty:: ClosureTy < ' tcx > {
177
- fty. fold_subitems_with ( self )
177
+ fty. super_fold_with ( self )
178
178
}
179
179
180
180
fn fold_region ( & mut self , r : ty:: Region ) -> ty:: Region {
181
- r. fold_subitems_with ( self )
181
+ r. super_fold_with ( self )
182
182
}
183
183
184
184
fn fold_existential_bounds ( & mut self , s : & ty:: ExistentialBounds < ' tcx > )
185
185
-> ty:: ExistentialBounds < ' tcx > {
186
- s. fold_subitems_with ( self )
186
+ s. super_fold_with ( self )
187
187
}
188
188
189
189
fn fold_autoref ( & mut self , ar : & adjustment:: AutoRef < ' tcx > )
190
190
-> adjustment:: AutoRef < ' tcx > {
191
- ar. fold_subitems_with ( self )
191
+ ar. super_fold_with ( self )
192
192
}
193
193
}
194
194
@@ -197,11 +197,11 @@ pub trait TypeVisitor<'tcx> : Sized {
197
197
fn exit_region_binder ( & mut self ) { }
198
198
199
199
fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> bool {
200
- t. visit_subitems_with ( self )
200
+ t. super_visit_with ( self )
201
201
}
202
202
203
203
fn visit_region ( & mut self , r : ty:: Region ) -> bool {
204
- r. visit_subitems_with ( self )
204
+ r. super_visit_with ( self )
205
205
}
206
206
}
207
207
@@ -219,7 +219,7 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
219
219
fn tcx ( & self ) -> & ty:: ctxt < ' tcx > { self . tcx }
220
220
221
221
fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
222
- let t1 = ty. fold_subitems_with ( self ) ;
222
+ let t1 = ty. super_fold_with ( self ) ;
223
223
( self . fldop ) ( t1)
224
224
}
225
225
}
@@ -447,7 +447,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
447
447
return t;
448
448
}
449
449
450
- t. fold_subitems_with ( self )
450
+ t. super_fold_with ( self )
451
451
}
452
452
453
453
fn fold_region ( & mut self , r : ty:: Region ) -> ty:: Region {
@@ -498,7 +498,7 @@ impl<'tcx> ty::ctxt<'tcx> {
498
498
Some ( u) => return u
499
499
}
500
500
501
- let t_norm = ty. fold_subitems_with ( self ) ;
501
+ let t_norm = ty. super_fold_with ( self ) ;
502
502
self . tcx ( ) . normalized_cache . borrow_mut ( ) . insert ( ty, t_norm) ;
503
503
return t_norm;
504
504
}
@@ -507,7 +507,7 @@ impl<'tcx> ty::ctxt<'tcx> {
507
507
where T : TypeFoldable < ' tcx >
508
508
{
509
509
let u = self . tcx ( ) . anonymize_late_bound_regions ( t) ;
510
- u. fold_subitems_with ( self )
510
+ u. super_fold_with ( self )
511
511
}
512
512
513
513
fn fold_region ( & mut self , r : ty:: Region ) -> ty:: Region {
0 commit comments