@@ -1518,77 +1518,7 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
1518
1518
}
1519
1519
}
1520
1520
1521
- // A custom iterator used by `Predicate::walk_tys`.
1522
- enum WalkTysIter < ' tcx , I , J , K >
1523
- where
1524
- I : Iterator < Item = Ty < ' tcx > > ,
1525
- J : Iterator < Item = Ty < ' tcx > > ,
1526
- K : Iterator < Item = Ty < ' tcx > > ,
1527
- {
1528
- None ,
1529
- One ( Ty < ' tcx > ) ,
1530
- Two ( Ty < ' tcx > , Ty < ' tcx > ) ,
1531
- Types ( I ) ,
1532
- InputTypes ( J ) ,
1533
- ProjectionTypes ( K ) ,
1534
- }
1535
-
1536
- impl < ' tcx , I , J , K > Iterator for WalkTysIter < ' tcx , I , J , K >
1537
- where
1538
- I : Iterator < Item = Ty < ' tcx > > ,
1539
- J : Iterator < Item = Ty < ' tcx > > ,
1540
- K : Iterator < Item = Ty < ' tcx > > ,
1541
- {
1542
- type Item = Ty < ' tcx > ;
1543
-
1544
- fn next ( & mut self ) -> Option < Ty < ' tcx > > {
1545
- match * self {
1546
- WalkTysIter :: None => None ,
1547
- WalkTysIter :: One ( item) => {
1548
- * self = WalkTysIter :: None ;
1549
- Some ( item)
1550
- }
1551
- WalkTysIter :: Two ( item1, item2) => {
1552
- * self = WalkTysIter :: One ( item2) ;
1553
- Some ( item1)
1554
- }
1555
- WalkTysIter :: Types ( ref mut iter) => iter. next ( ) ,
1556
- WalkTysIter :: InputTypes ( ref mut iter) => iter. next ( ) ,
1557
- WalkTysIter :: ProjectionTypes ( ref mut iter) => iter. next ( ) ,
1558
- }
1559
- }
1560
- }
1561
-
1562
1521
impl < ' tcx > Predicate < ' tcx > {
1563
- /// Iterates over the types in this predicate. Note that in all
1564
- /// cases this is skipping over a binder, so late-bound regions
1565
- /// with depth 0 are bound by the predicate.
1566
- pub fn walk_tys ( & ' a self ) -> impl Iterator < Item = Ty < ' tcx > > + ' a {
1567
- match * self {
1568
- ty:: Predicate :: Trait ( ref data, _) => {
1569
- WalkTysIter :: InputTypes ( data. skip_binder ( ) . input_types ( ) )
1570
- }
1571
- ty:: Predicate :: Subtype ( binder) => {
1572
- let SubtypePredicate { a, b, a_is_expected : _ } = binder. skip_binder ( ) ;
1573
- WalkTysIter :: Two ( a, b)
1574
- }
1575
- ty:: Predicate :: TypeOutlives ( binder) => WalkTysIter :: One ( binder. skip_binder ( ) . 0 ) ,
1576
- ty:: Predicate :: RegionOutlives ( ..) => WalkTysIter :: None ,
1577
- ty:: Predicate :: Projection ( ref data) => {
1578
- let inner = data. skip_binder ( ) ;
1579
- WalkTysIter :: ProjectionTypes (
1580
- inner. projection_ty . substs . types ( ) . chain ( Some ( inner. ty ) ) ,
1581
- )
1582
- }
1583
- ty:: Predicate :: WellFormed ( data) => WalkTysIter :: One ( data) ,
1584
- ty:: Predicate :: ObjectSafe ( _trait_def_id) => WalkTysIter :: None ,
1585
- ty:: Predicate :: ClosureKind ( _closure_def_id, closure_substs, _kind) => {
1586
- WalkTysIter :: Types ( closure_substs. types ( ) )
1587
- }
1588
- ty:: Predicate :: ConstEvaluatable ( _, substs) => WalkTysIter :: Types ( substs. types ( ) ) ,
1589
- }
1590
- }
1591
-
1592
1522
pub fn to_opt_poly_trait_ref ( & self ) -> Option < PolyTraitRef < ' tcx > > {
1593
1523
match * self {
1594
1524
Predicate :: Trait ( ref t, _) => Some ( t. to_poly_trait_ref ( ) ) ,
0 commit comments