@@ -310,14 +310,7 @@ pub trait TypeFolder<I: Interner> {
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
312
312
/// `T`; well, actually `T::Result`).
313
- pub trait TypeFoldable < I : Interner > : Debug {
314
- /// The type of value that will be produced once folding is done.
315
- /// Typically this is `Self`, unless `Self` contains borrowed
316
- /// values, in which case owned values are produced (for example,
317
- /// one can fold over a `&T` value where `T: TypeFoldable`, in which case
318
- /// you get back a `T`, not a `&T`).
319
- type Result ;
320
-
313
+ pub trait TypeFoldable < I : Interner > : Debug + Sized {
321
314
/// Apply the given folder `folder` to `self`; `binders` is the
322
315
/// number of binders that are in scope when beginning the
323
316
/// folder. Typically `binders` starts as 0, but is adjusted when
@@ -327,7 +320,7 @@ pub trait TypeFoldable<I: Interner>: Debug {
327
320
self ,
328
321
folder : & mut dyn TypeFolder < I , Error = E > ,
329
322
outer_binder : DebruijnIndex ,
330
- ) -> Result < Self :: Result , E > ;
323
+ ) -> Result < Self , E > ;
331
324
}
332
325
333
326
/// For types where "fold" invokes a callback on the `TypeFolder`, the
@@ -339,20 +332,18 @@ pub trait TypeSuperFoldable<I: Interner>: TypeFoldable<I> {
339
332
self ,
340
333
folder : & mut dyn TypeFolder < I , Error = E > ,
341
334
outer_binder : DebruijnIndex ,
342
- ) -> Result < Self :: Result , E > ;
335
+ ) -> Result < Self , E > ;
343
336
}
344
337
345
338
/// "Folding" a type invokes the `fold_ty` method on the folder; this
346
339
/// usually (in turn) invokes `super_fold_ty` to fold the individual
347
340
/// parts.
348
341
impl < I : Interner > TypeFoldable < I > for Ty < I > {
349
- type Result = Ty < I > ;
350
-
351
342
fn fold_with < E > (
352
343
self ,
353
344
folder : & mut dyn TypeFolder < I , Error = E > ,
354
345
outer_binder : DebruijnIndex ,
355
- ) -> Result < Self :: Result , E > {
346
+ ) -> Result < Self , E > {
356
347
folder. fold_ty ( self , outer_binder)
357
348
}
358
349
}
@@ -470,13 +461,11 @@ where
470
461
/// usually (in turn) invokes `super_fold_lifetime` to fold the individual
471
462
/// parts.
472
463
impl < I : Interner > TypeFoldable < I > for Lifetime < I > {
473
- type Result = Lifetime < I > ;
474
-
475
464
fn fold_with < E > (
476
465
self ,
477
466
folder : & mut dyn TypeFolder < I , Error = E > ,
478
467
outer_binder : DebruijnIndex ,
479
- ) -> Result < Self :: Result , E > {
468
+ ) -> Result < Self , E > {
480
469
folder. fold_lifetime ( self , outer_binder)
481
470
}
482
471
}
@@ -522,13 +511,11 @@ where
522
511
/// usually (in turn) invokes `super_fold_const` to fold the individual
523
512
/// parts.
524
513
impl < I : Interner > TypeFoldable < I > for Const < I > {
525
- type Result = Const < I > ;
526
-
527
514
fn fold_with < E > (
528
515
self ,
529
516
folder : & mut dyn TypeFolder < I , Error = E > ,
530
517
outer_binder : DebruijnIndex ,
531
- ) -> Result < Self :: Result , E > {
518
+ ) -> Result < Self , E > {
532
519
folder. fold_const ( self , outer_binder)
533
520
}
534
521
}
@@ -573,13 +560,11 @@ where
573
560
/// Folding a goal invokes the `fold_goal` callback (which will, by
574
561
/// default, invoke super-fold).
575
562
impl < I : Interner > TypeFoldable < I > for Goal < I > {
576
- type Result = Goal < I > ;
577
-
578
563
fn fold_with < E > (
579
564
self ,
580
565
folder : & mut dyn TypeFolder < I , Error = E > ,
581
566
outer_binder : DebruijnIndex ,
582
- ) -> Result < Self :: Result , E > {
567
+ ) -> Result < Self , E > {
583
568
folder. fold_goal ( self , outer_binder)
584
569
}
585
570
}
@@ -590,7 +575,7 @@ impl<I: Interner> TypeSuperFoldable<I> for Goal<I> {
590
575
self ,
591
576
folder : & mut dyn TypeFolder < I , Error = E > ,
592
577
outer_binder : DebruijnIndex ,
593
- ) -> Result < Self :: Result , E > {
578
+ ) -> Result < Self , E > {
594
579
let interner = folder. interner ( ) ;
595
580
Ok ( Goal :: new (
596
581
interner,
@@ -605,13 +590,11 @@ impl<I: Interner> TypeSuperFoldable<I> for Goal<I> {
605
590
/// callback on the folder (which will, by default, invoke the
606
591
/// `super_fold_with` method on the program clause).
607
592
impl < I : Interner > TypeFoldable < I > for ProgramClause < I > {
608
- type Result = ProgramClause < I > ;
609
-
610
593
fn fold_with < E > (
611
594
self ,
612
595
folder : & mut dyn TypeFolder < I , Error = E > ,
613
596
outer_binder : DebruijnIndex ,
614
- ) -> Result < Self :: Result , E > {
597
+ ) -> Result < Self , E > {
615
598
folder. fold_program_clause ( self , outer_binder)
616
599
}
617
600
}
0 commit comments