@@ -413,98 +413,3 @@ where
413
413
( self . 0 ) ( f)
414
414
}
415
415
}
416
-
417
- pub ( crate ) trait PatternFoldable : Sized {
418
- fn fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
419
- self . super_fold_with ( folder)
420
- }
421
-
422
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self ;
423
- }
424
-
425
- pub ( crate ) trait PatternFolder : Sized {
426
- fn fold_pattern ( & mut self , pattern : & Pat ) -> Pat {
427
- pattern. super_fold_with ( self )
428
- }
429
-
430
- fn fold_pattern_kind ( & mut self , kind : & PatKind ) -> PatKind {
431
- kind. super_fold_with ( self )
432
- }
433
- }
434
-
435
- impl < T : PatternFoldable > PatternFoldable for Box < T > {
436
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
437
- let content: T = ( * * self ) . fold_with ( folder) ;
438
- Box :: new ( content)
439
- }
440
- }
441
-
442
- impl < T : PatternFoldable > PatternFoldable for Vec < T > {
443
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
444
- self . iter ( ) . map ( |t| t. fold_with ( folder) ) . collect ( )
445
- }
446
- }
447
-
448
- impl < T : PatternFoldable > PatternFoldable for Option < T > {
449
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
450
- self . as_ref ( ) . map ( |t| t. fold_with ( folder) )
451
- }
452
- }
453
-
454
- macro_rules! clone_impls {
455
- ( $( $ty: ty) ,+) => {
456
- $(
457
- impl PatternFoldable for $ty {
458
- fn super_fold_with<F : PatternFolder >( & self , _: & mut F ) -> Self {
459
- Clone :: clone( self )
460
- }
461
- }
462
- ) +
463
- }
464
- }
465
-
466
- clone_impls ! { LocalFieldId , Ty , Substitution , EnumVariantId }
467
-
468
- impl PatternFoldable for FieldPat {
469
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
470
- FieldPat { field : self . field . fold_with ( folder) , pattern : self . pattern . fold_with ( folder) }
471
- }
472
- }
473
-
474
- impl PatternFoldable for Pat {
475
- fn fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
476
- folder. fold_pattern ( self )
477
- }
478
-
479
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
480
- Pat { ty : self . ty . fold_with ( folder) , kind : self . kind . fold_with ( folder) }
481
- }
482
- }
483
-
484
- impl PatternFoldable for PatKind {
485
- fn fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
486
- folder. fold_pattern_kind ( self )
487
- }
488
-
489
- fn super_fold_with < F : PatternFolder > ( & self , folder : & mut F ) -> Self {
490
- match self {
491
- PatKind :: Wild => PatKind :: Wild ,
492
- PatKind :: Binding { name, subpattern } => {
493
- PatKind :: Binding { name : name. clone ( ) , subpattern : subpattern. fold_with ( folder) }
494
- }
495
- PatKind :: Variant { substs, enum_variant, subpatterns } => PatKind :: Variant {
496
- substs : substs. fold_with ( folder) ,
497
- enum_variant : enum_variant. fold_with ( folder) ,
498
- subpatterns : subpatterns. fold_with ( folder) ,
499
- } ,
500
- PatKind :: Leaf { subpatterns } => {
501
- PatKind :: Leaf { subpatterns : subpatterns. fold_with ( folder) }
502
- }
503
- PatKind :: Deref { subpattern } => {
504
- PatKind :: Deref { subpattern : subpattern. fold_with ( folder) }
505
- }
506
- & PatKind :: LiteralBool { value } => PatKind :: LiteralBool { value } ,
507
- PatKind :: Or { pats } => PatKind :: Or { pats : pats. fold_with ( folder) } ,
508
- }
509
- }
510
- }
0 commit comments