@@ -1042,7 +1042,30 @@ impl<'tcx> Predicate<'tcx> {
10421042    } 
10431043
10441044    /// Skips `PredicateKind::ForAll`. 
1045- pub  fn  ignore_qualifiers ( self ,  tcx :  TyCtxt < ' tcx > )  -> Binder < Predicate < ' tcx > >  { 
1045+ pub  fn  ignore_qualifiers ( self )  -> Binder < Predicate < ' tcx > >  { 
1046+         match  self . kind ( )  { 
1047+             & PredicateKind :: ForAll ( binder)  => binder, 
1048+             ty:: PredicateKind :: Projection ( ..) 
1049+             | ty:: PredicateKind :: Trait ( ..) 
1050+             | ty:: PredicateKind :: Subtype ( ..) 
1051+             | ty:: PredicateKind :: WellFormed ( ..) 
1052+             | ty:: PredicateKind :: ObjectSafe ( ..) 
1053+             | ty:: PredicateKind :: ClosureKind ( ..) 
1054+             | ty:: PredicateKind :: TypeOutlives ( ..) 
1055+             | ty:: PredicateKind :: ConstEvaluatable ( ..) 
1056+             | ty:: PredicateKind :: ConstEquate ( ..) 
1057+             | ty:: PredicateKind :: RegionOutlives ( ..)  => Binder :: dummy ( self ) , 
1058+         } 
1059+     } 
1060+ 
1061+     /// Skips `PredicateKind::ForAll`, while allowing for unbound variables. 
1062+ /// 
1063+ /// This method requires the `TyCtxt` as it has to shift the unbound variables 
1064+ /// outwards. 
1065+ /// 
1066+ /// Do not use this method if you may end up just skipping the binder, as this 
1067+ /// would leave the unbound variables at an incorrect binding level. 
1068+ pub  fn  ignore_qualifiers_with_unbound_vars ( self ,  tcx :  TyCtxt < ' tcx > )  -> Binder < Predicate < ' tcx > >  { 
10461069        match  self . kind ( )  { 
10471070            & PredicateKind :: ForAll ( binder)  => binder, 
10481071            ty:: PredicateKind :: Projection ( ..) 
@@ -1218,7 +1241,7 @@ impl<'tcx> Predicate<'tcx> {
12181241        // from the substitution and the value being substituted into, and 
12191242        // this trick achieves that). 
12201243        let  substs = trait_ref. skip_binder ( ) . substs ; 
1221-         let  pred = * self . ignore_qualifiers ( tcx ) . skip_binder ( ) ; 
1244+         let  pred = * self . ignore_qualifiers ( ) . skip_binder ( ) ; 
12221245        let  new = pred. subst ( tcx,  substs) ; 
12231246        if  new != pred {  new. potentially_qualified ( tcx,  PredicateKind :: ForAll )  }  else  {  self  } 
12241247    } 
@@ -1419,8 +1442,8 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
14191442} 
14201443
14211444impl < ' tcx >  Predicate < ' tcx >  { 
1422-     pub  fn  to_opt_poly_trait_ref ( self ,   tcx :   TyCtxt < ' tcx > )  -> Option < PolyTraitRef < ' tcx > >  { 
1423-         self . ignore_qualifiers ( tcx ) 
1445+     pub  fn  to_opt_poly_trait_ref ( self )  -> Option < PolyTraitRef < ' tcx > >  { 
1446+         self . ignore_qualifiers ( ) 
14241447            . map_bound ( |pred| match  pred. kind ( )  { 
14251448                & PredicateKind :: Trait ( ref  t,  _)  => Some ( t. trait_ref ) , 
14261449                PredicateKind :: Projection ( ..) 
@@ -1437,11 +1460,8 @@ impl<'tcx> Predicate<'tcx> {
14371460            . transpose ( ) 
14381461    } 
14391462
1440-     pub  fn  to_opt_type_outlives ( 
1441-         self , 
1442-         tcx :  TyCtxt < ' tcx > , 
1443-     )  -> Option < PolyTypeOutlivesPredicate < ' tcx > >  { 
1444-         self . ignore_qualifiers ( tcx) 
1463+     pub  fn  to_opt_type_outlives ( self )  -> Option < PolyTypeOutlivesPredicate < ' tcx > >  { 
1464+         self . ignore_qualifiers ( ) 
14451465            . map_bound ( |pred| match  pred. kind ( )  { 
14461466                & PredicateKind :: TypeOutlives ( data)  => Some ( data) , 
14471467                PredicateKind :: Trait ( ..) 
0 commit comments