@@ -17,7 +17,7 @@ pub use self::subst::Subst;
17
17
/// certain changes applied. The idea is that it contains methods that
18
18
/// let you swap types/lifetimes for new types/lifetimes; meanwhile,
19
19
/// each bit of IR implements the `TypeFoldable` trait which, given a
20
- /// `Folder `, will reconstruct itself, invoking the folder's methods
20
+ /// `TypeFolder `, will reconstruct itself, invoking the folder's methods
21
21
/// to transform each of the types/lifetimes embedded within.
22
22
///
23
23
/// # Usage patterns
@@ -29,14 +29,14 @@ pub use self::subst::Subst;
29
29
/// more often, just free existential variables) that appear within
30
30
/// the term.
31
31
///
32
- /// For this reason, the `Folder ` trait extends two other traits that
32
+ /// For this reason, the `TypeFolder ` trait extends two other traits that
33
33
/// contain methods that are invoked when just those particular
34
34
///
35
35
/// In particular, folders can intercept references to free variables
36
36
/// (either existentially or universally quantified) and replace them
37
37
/// with other types/lifetimes as appropriate.
38
38
///
39
- /// To create a folder `F`, one never implements `Folder ` directly, but instead
39
+ /// To create a folder `F`, one never implements `TypeFolder ` directly, but instead
40
40
/// implements one of each of these three sub-traits:
41
41
///
42
42
/// - `FreeVarFolder` -- folds `BoundVar` instances that appear free
@@ -54,19 +54,19 @@ pub use self::subst::Subst;
54
54
/// ```rust,ignore
55
55
/// let x = x.fold_with(&mut folder, 0);
56
56
/// ```
57
- pub trait Folder < I : Interner > {
57
+ pub trait TypeFolder < I : Interner > {
58
58
/// The type this folder returns when folding fails. This is
59
59
/// commonly [`NoSolution`].
60
60
type Error ;
61
61
62
62
/// Creates a `dyn` value from this folder. Unfortunately, this
63
- /// must be added manually to each impl of Folder ; it permits the
64
- /// default implements below to create a `&mut dyn Folder ` from
63
+ /// must be added manually to each impl of TypeFolder ; it permits the
64
+ /// default implements below to create a `&mut dyn TypeFolder ` from
65
65
/// `Self` without knowing what `Self` is (by invoking this
66
- /// method). Effectively, this limits impls of `Folder ` to types
66
+ /// method). Effectively, this limits impls of `TypeFolder ` to types
67
67
/// for which we are able to create a dyn value (i.e., not `[T]`
68
68
/// types).
69
- fn as_dyn ( & mut self ) -> & mut dyn Folder < I , Error = Self :: Error > ;
69
+ fn as_dyn ( & mut self ) -> & mut dyn TypeFolder < I , Error = Self :: Error > ;
70
70
71
71
/// Top-level callback: invoked for each `Ty<I>` that is
72
72
/// encountered when folding. By default, invokes
@@ -305,7 +305,7 @@ pub trait Folder<I: Interner> {
305
305
fn interner ( & self ) -> I ;
306
306
}
307
307
308
- /// Applies the given `Folder ` to a value, producing a folded result
308
+ /// Applies the given `TypeFolder ` to a value, producing a folded result
309
309
/// of type `Self::Result`. The result type is typically the same as
310
310
/// the source type, but in some cases we convert from borrowed
311
311
/// to owned as well (e.g., the folder for `&T` will fold to a fresh
@@ -325,19 +325,19 @@ pub trait TypeFoldable<I: Interner>: Debug {
325
325
/// constructs.
326
326
fn fold_with < E > (
327
327
self ,
328
- folder : & mut dyn Folder < I , Error = E > ,
328
+ folder : & mut dyn TypeFolder < I , Error = E > ,
329
329
outer_binder : DebruijnIndex ,
330
330
) -> Result < Self :: Result , E > ;
331
331
}
332
332
333
- /// For types where "fold" invokes a callback on the `Folder `, the
333
+ /// For types where "fold" invokes a callback on the `TypeFolder `, the
334
334
/// `TypeSuperFoldable` trait captures the recursive behavior that folds all
335
335
/// the contents of the type.
336
336
pub trait TypeSuperFoldable < I : Interner > : TypeFoldable < I > {
337
337
/// Recursively folds the value.
338
338
fn super_fold_with < E > (
339
339
self ,
340
- folder : & mut dyn Folder < I , Error = E > ,
340
+ folder : & mut dyn TypeFolder < I , Error = E > ,
341
341
outer_binder : DebruijnIndex ,
342
342
) -> Result < Self :: Result , E > ;
343
343
}
@@ -350,7 +350,7 @@ impl<I: Interner> TypeFoldable<I> for Ty<I> {
350
350
351
351
fn fold_with < E > (
352
352
self ,
353
- folder : & mut dyn Folder < I , Error = E > ,
353
+ folder : & mut dyn TypeFolder < I , Error = E > ,
354
354
outer_binder : DebruijnIndex ,
355
355
) -> Result < Self :: Result , E > {
356
356
folder. fold_ty ( self , outer_binder)
@@ -364,7 +364,7 @@ where
364
364
{
365
365
fn super_fold_with < E > (
366
366
self ,
367
- folder : & mut dyn Folder < I , Error = E > ,
367
+ folder : & mut dyn TypeFolder < I , Error = E > ,
368
368
outer_binder : DebruijnIndex ,
369
369
) -> Result < Ty < I > , E > {
370
370
let interner = folder. interner ( ) ;
@@ -474,7 +474,7 @@ impl<I: Interner> TypeFoldable<I> for Lifetime<I> {
474
474
475
475
fn fold_with < E > (
476
476
self ,
477
- folder : & mut dyn Folder < I , Error = E > ,
477
+ folder : & mut dyn TypeFolder < I , Error = E > ,
478
478
outer_binder : DebruijnIndex ,
479
479
) -> Result < Self :: Result , E > {
480
480
folder. fold_lifetime ( self , outer_binder)
@@ -487,7 +487,7 @@ where
487
487
{
488
488
fn super_fold_with < E > (
489
489
self ,
490
- folder : & mut dyn Folder < I , Error = E > ,
490
+ folder : & mut dyn TypeFolder < I , Error = E > ,
491
491
outer_binder : DebruijnIndex ,
492
492
) -> Result < Lifetime < I > , E > {
493
493
let interner = folder. interner ( ) ;
@@ -526,7 +526,7 @@ impl<I: Interner> TypeFoldable<I> for Const<I> {
526
526
527
527
fn fold_with < E > (
528
528
self ,
529
- folder : & mut dyn Folder < I , Error = E > ,
529
+ folder : & mut dyn TypeFolder < I , Error = E > ,
530
530
outer_binder : DebruijnIndex ,
531
531
) -> Result < Self :: Result , E > {
532
532
folder. fold_const ( self , outer_binder)
@@ -539,7 +539,7 @@ where
539
539
{
540
540
fn super_fold_with < E > (
541
541
self ,
542
- folder : & mut dyn Folder < I , Error = E > ,
542
+ folder : & mut dyn TypeFolder < I , Error = E > ,
543
543
outer_binder : DebruijnIndex ,
544
544
) -> Result < Const < I > , E > {
545
545
let interner = folder. interner ( ) ;
@@ -577,7 +577,7 @@ impl<I: Interner> TypeFoldable<I> for Goal<I> {
577
577
578
578
fn fold_with < E > (
579
579
self ,
580
- folder : & mut dyn Folder < I , Error = E > ,
580
+ folder : & mut dyn TypeFolder < I , Error = E > ,
581
581
outer_binder : DebruijnIndex ,
582
582
) -> Result < Self :: Result , E > {
583
583
folder. fold_goal ( self , outer_binder)
@@ -588,7 +588,7 @@ impl<I: Interner> TypeFoldable<I> for Goal<I> {
588
588
impl < I : Interner > TypeSuperFoldable < I > for Goal < I > {
589
589
fn super_fold_with < E > (
590
590
self ,
591
- folder : & mut dyn Folder < I , Error = E > ,
591
+ folder : & mut dyn TypeFolder < I , Error = E > ,
592
592
outer_binder : DebruijnIndex ,
593
593
) -> Result < Self :: Result , E > {
594
594
let interner = folder. interner ( ) ;
@@ -609,7 +609,7 @@ impl<I: Interner> TypeFoldable<I> for ProgramClause<I> {
609
609
610
610
fn fold_with < E > (
611
611
self ,
612
- folder : & mut dyn Folder < I , Error = E > ,
612
+ folder : & mut dyn TypeFolder < I , Error = E > ,
613
613
outer_binder : DebruijnIndex ,
614
614
) -> Result < Self :: Result , E > {
615
615
folder. fold_program_clause ( self , outer_binder)
0 commit comments