Skip to content

Commit 6327563

Browse files
committed
Rename fold_subitems_with to super_fold_with
1 parent 76021d8 commit 6327563

File tree

9 files changed

+182
-183
lines changed

9 files changed

+182
-183
lines changed

src/librustc/middle/infer/combine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
318318
}
319319
}
320320
_ => {
321-
t.fold_subitems_with(self)
321+
t.super_fold_with(self)
322322
}
323323
}
324324
}

src/librustc/middle/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
168168
ty::TyTuple(..) |
169169
ty::TyProjection(..) |
170170
ty::TyParam(..) => {
171-
t.fold_subitems_with(self)
171+
t.super_fold_with(self)
172172
}
173173
}
174174
}

src/librustc/middle/infer/resolve.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx
3939
t // micro-optimize -- if there is nothing in this type that this fold affects...
4040
} else {
4141
let t0 = self.infcx.shallow_resolve(t);
42-
t0.fold_subitems_with(self)
42+
t0.super_fold_with(self)
4343
}
4444
}
4545
}
@@ -67,7 +67,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver
6767
t // micro-optimize -- if there is nothing in this type that this fold affects...
6868
} else {
6969
let t0 = self.infcx.shallow_resolve(t);
70-
t0.fold_subitems_with(self)
70+
t0.super_fold_with(self)
7171
}
7272
}
7373

@@ -132,7 +132,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
132132
t));
133133
}
134134
_ => {
135-
t.fold_subitems_with(self)
135+
t.super_fold_with(self)
136136
}
137137
}
138138
}

src/librustc/middle/subst.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
674674
self.ty_for_param(p, t)
675675
}
676676
_ => {
677-
t.fold_subitems_with(self)
677+
t.super_fold_with(self)
678678
}
679679
};
680680

src/librustc/middle/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl<'a,'b,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'b,'tcx> {
273273
// normalize it when we instantiate those bound regions (which
274274
// should occur eventually).
275275

276-
let ty = ty.fold_subitems_with(self);
276+
let ty = ty.super_fold_with(self);
277277
match ty.sty {
278278
ty::TyProjection(ref data) if !data.has_escaping_regions() => { // (*)
279279

src/librustc/middle/traits/structural_impls.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -132,87 +132,87 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
132132

133133
impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O>
134134
{
135-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Obligation<'tcx, O> {
135+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
136136
traits::Obligation {
137137
cause: self.cause.clone(),
138138
recursion_depth: self.recursion_depth,
139139
predicate: self.predicate.fold_with(folder),
140140
}
141141
}
142142

143-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
143+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
144144
self.predicate.visit_with(visitor)
145145
}
146146
}
147147

148148
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableImplData<'tcx, N> {
149-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableImplData<'tcx, N> {
149+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
150150
traits::VtableImplData {
151151
impl_def_id: self.impl_def_id,
152152
substs: self.substs.fold_with(folder),
153153
nested: self.nested.fold_with(folder),
154154
}
155155
}
156156

157-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
157+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
158158
self.substs.visit_with(visitor) || self.nested.visit_with(visitor)
159159
}
160160
}
161161

162162
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableClosureData<'tcx, N> {
163-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableClosureData<'tcx, N> {
163+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
164164
traits::VtableClosureData {
165165
closure_def_id: self.closure_def_id,
166166
substs: self.substs.fold_with(folder),
167167
nested: self.nested.fold_with(folder),
168168
}
169169
}
170170

171-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
171+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
172172
self.substs.visit_with(visitor) || self.nested.visit_with(visitor)
173173
}
174174
}
175175

176176
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableDefaultImplData<N> {
177-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableDefaultImplData<N> {
177+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
178178
traits::VtableDefaultImplData {
179179
trait_def_id: self.trait_def_id,
180180
nested: self.nested.fold_with(folder),
181181
}
182182
}
183183

184-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
184+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
185185
self.nested.visit_with(visitor)
186186
}
187187
}
188188

189189
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
190-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableBuiltinData<N> {
190+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
191191
traits::VtableBuiltinData {
192192
nested: self.nested.fold_with(folder),
193193
}
194194
}
195195

196-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
196+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
197197
self.nested.visit_with(visitor)
198198
}
199199
}
200200

201201
impl<'tcx> TypeFoldable<'tcx> for traits::VtableObjectData<'tcx> {
202-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableObjectData<'tcx> {
202+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
203203
traits::VtableObjectData {
204204
upcast_trait_ref: self.upcast_trait_ref.fold_with(folder),
205205
vtable_base: self.vtable_base
206206
}
207207
}
208208

209-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
209+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
210210
self.upcast_trait_ref.visit_with(visitor)
211211
}
212212
}
213213

214214
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N> {
215-
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<'tcx, N> {
215+
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
216216
match *self {
217217
traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
218218
traits::VtableDefaultImpl(ref t) => traits::VtableDefaultImpl(t.fold_with(folder)),
@@ -228,7 +228,7 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
228228
}
229229
}
230230

231-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
231+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
232232
match *self {
233233
traits::VtableImpl(ref v) => v.visit_with(visitor),
234234
traits::VtableDefaultImpl(ref t) => t.visit_with(visitor),
@@ -242,14 +242,14 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
242242
}
243243

244244
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
245-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Normalized<'tcx, T> {
245+
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
246246
Normalized {
247247
value: self.value.fold_with(folder),
248248
obligations: self.obligations.fold_with(folder),
249249
}
250250
}
251251

252-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
252+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
253253
self.value.visit_with(visitor) || self.obligations.visit_with(visitor)
254254
}
255255
}

src/librustc/middle/ty/fold.rs

+29-29
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
//! instance of a "folder" (a type which implements `TypeFolder`). Then
1515
//! the setup is intended to be:
1616
//!
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)
1818
//!
1919
//! 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()`
2121
//! to get the original behavior. Meanwhile, to actually fold
2222
//! something, you can just write `T.fold_with(F)`, which is
2323
//! convenient. (Note that `fold_with` will also transparently handle
2424
//! things like a `Vec<T>` where T is foldable and so on.)
2525
//!
2626
//! 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()`.
2929
//!
3030
//! In some cases, we follow a degenerate pattern where we do not have
3131
//! a `fold_T` method. Instead, `T.fold_with` traverses the structure directly.
@@ -35,7 +35,7 @@
3535
//! proper thing.
3636
//!
3737
//! 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).
3939
//! These methods return true to indicate that the visitor has found what it is looking for
4040
//! and does not need to visit anything else.
4141
@@ -50,14 +50,14 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
5050
/// The TypeFoldable trait is implemented for every type that can be folded.
5151
/// Basically, every type that has a corresponding method in TypeFolder.
5252
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)
5656
}
5757

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)
6161
}
6262

6363
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
@@ -131,64 +131,64 @@ pub trait TypeFolder<'tcx> : Sized {
131131
where T : TypeFoldable<'tcx>
132132
{
133133
// FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
134-
t.fold_subitems_with(self)
134+
t.super_fold_with(self)
135135
}
136136

137137
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
138-
t.fold_subitems_with(self)
138+
t.super_fold_with(self)
139139
}
140140

141141
fn fold_mt(&mut self, t: &ty::TypeAndMut<'tcx>) -> ty::TypeAndMut<'tcx> {
142-
t.fold_subitems_with(self)
142+
t.super_fold_with(self)
143143
}
144144

145145
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)
147147
}
148148

149149
fn fold_substs(&mut self,
150150
substs: &subst::Substs<'tcx>)
151151
-> subst::Substs<'tcx> {
152-
substs.fold_subitems_with(self)
152+
substs.super_fold_with(self)
153153
}
154154

155155
fn fold_fn_sig(&mut self,
156156
sig: &ty::FnSig<'tcx>)
157157
-> ty::FnSig<'tcx> {
158-
sig.fold_subitems_with(self)
158+
sig.super_fold_with(self)
159159
}
160160

161161
fn fold_output(&mut self,
162162
output: &ty::FnOutput<'tcx>)
163163
-> ty::FnOutput<'tcx> {
164-
output.fold_subitems_with(self)
164+
output.super_fold_with(self)
165165
}
166166

167167
fn fold_bare_fn_ty(&mut self,
168168
fty: &ty::BareFnTy<'tcx>)
169169
-> ty::BareFnTy<'tcx>
170170
{
171-
fty.fold_subitems_with(self)
171+
fty.super_fold_with(self)
172172
}
173173

174174
fn fold_closure_ty(&mut self,
175175
fty: &ty::ClosureTy<'tcx>)
176176
-> ty::ClosureTy<'tcx> {
177-
fty.fold_subitems_with(self)
177+
fty.super_fold_with(self)
178178
}
179179

180180
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
181-
r.fold_subitems_with(self)
181+
r.super_fold_with(self)
182182
}
183183

184184
fn fold_existential_bounds(&mut self, s: &ty::ExistentialBounds<'tcx>)
185185
-> ty::ExistentialBounds<'tcx> {
186-
s.fold_subitems_with(self)
186+
s.super_fold_with(self)
187187
}
188188

189189
fn fold_autoref(&mut self, ar: &adjustment::AutoRef<'tcx>)
190190
-> adjustment::AutoRef<'tcx> {
191-
ar.fold_subitems_with(self)
191+
ar.super_fold_with(self)
192192
}
193193
}
194194

@@ -197,11 +197,11 @@ pub trait TypeVisitor<'tcx> : Sized {
197197
fn exit_region_binder(&mut self) { }
198198

199199
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
200-
t.visit_subitems_with(self)
200+
t.super_visit_with(self)
201201
}
202202

203203
fn visit_region(&mut self, r: ty::Region) -> bool {
204-
r.visit_subitems_with(self)
204+
r.super_visit_with(self)
205205
}
206206
}
207207

@@ -219,7 +219,7 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
219219
fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx }
220220

221221
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);
223223
(self.fldop)(t1)
224224
}
225225
}
@@ -447,7 +447,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
447447
return t;
448448
}
449449

450-
t.fold_subitems_with(self)
450+
t.super_fold_with(self)
451451
}
452452

453453
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
@@ -498,7 +498,7 @@ impl<'tcx> ty::ctxt<'tcx> {
498498
Some(u) => return u
499499
}
500500

501-
let t_norm = ty.fold_subitems_with(self);
501+
let t_norm = ty.super_fold_with(self);
502502
self.tcx().normalized_cache.borrow_mut().insert(ty, t_norm);
503503
return t_norm;
504504
}
@@ -507,7 +507,7 @@ impl<'tcx> ty::ctxt<'tcx> {
507507
where T : TypeFoldable<'tcx>
508508
{
509509
let u = self.tcx().anonymize_late_bound_regions(t);
510-
u.fold_subitems_with(self)
510+
u.super_fold_with(self)
511511
}
512512

513513
fn fold_region(&mut self, r: ty::Region) -> ty::Region {

0 commit comments

Comments
 (0)