@@ -15,7 +15,7 @@ use rustc_middle::mir::ConstraintCategory;
1515use rustc_middle:: query:: Providers ;
1616use rustc_middle:: ty:: trait_def:: TraitSpecializationKind ;
1717use rustc_middle:: ty:: {
18- self , AdtKind , GenericParamDefKind , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
18+ self , AdtKind , GenericParamDefKind , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
1919 TypeVisitable , TypeVisitableExt , TypeVisitor ,
2020} ;
2121use rustc_middle:: ty:: { GenericArgKind , InternalSubsts } ;
@@ -322,7 +322,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
322322 // Gather the bounds with which all other items inside of this trait constrain the GAT.
323323 // This is calculated by taking the intersection of the bounds that each item
324324 // constrains the GAT with individually.
325- let mut new_required_bounds: Option < FxHashSet < ty:: Predicate < ' _ > > > = None ;
325+ let mut new_required_bounds: Option < FxHashSet < ty:: Clause < ' _ > > > = None ;
326326 for item in associated_items {
327327 let item_def_id = item. id . owner_id ;
328328 // Skip our own GAT, since it does not constrain itself at all.
@@ -419,28 +419,25 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
419419 let mut unsatisfied_bounds: Vec < _ > = required_bounds
420420 . into_iter ( )
421421 . filter ( |clause| match clause. kind ( ) . skip_binder ( ) {
422- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives (
423- ty:: OutlivesPredicate ( a, b) ,
424- ) ) => !region_known_to_outlive (
425- tcx,
426- gat_def_id. def_id ,
427- param_env,
428- & FxIndexSet :: default ( ) ,
429- a,
430- b,
431- ) ,
432- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate (
433- a,
434- b,
435- ) ) ) => !ty_known_to_outlive (
422+ ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate ( a, b) ) => {
423+ !region_known_to_outlive (
424+ tcx,
425+ gat_def_id. def_id ,
426+ param_env,
427+ & FxIndexSet :: default ( ) ,
428+ a,
429+ b,
430+ )
431+ }
432+ ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( a, b) ) => !ty_known_to_outlive (
436433 tcx,
437434 gat_def_id. def_id ,
438435 param_env,
439436 & FxIndexSet :: default ( ) ,
440437 a,
441438 b,
442439 ) ,
443- _ => bug ! ( "Unexpected PredicateKind " ) ,
440+ _ => bug ! ( "Unexpected ClauseKind " ) ,
444441 } )
445442 . map ( |clause| clause. to_string ( ) )
446443 . collect ( ) ;
@@ -488,7 +485,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
488485fn augment_param_env < ' tcx > (
489486 tcx : TyCtxt < ' tcx > ,
490487 param_env : ty:: ParamEnv < ' tcx > ,
491- new_predicates : Option < & FxHashSet < ty:: Predicate < ' tcx > > > ,
488+ new_predicates : Option < & FxHashSet < ty:: Clause < ' tcx > > > ,
492489) -> ty:: ParamEnv < ' tcx > {
493490 let Some ( new_predicates) = new_predicates else {
494491 return param_env;
@@ -524,7 +521,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
524521 wf_tys : & FxIndexSet < Ty < ' tcx > > ,
525522 gat_def_id : LocalDefId ,
526523 gat_generics : & ' tcx ty:: Generics ,
527- ) -> Option < FxHashSet < ty:: Predicate < ' tcx > > > {
524+ ) -> Option < FxHashSet < ty:: Clause < ' tcx > > > {
528525 // The bounds we that we would require from `to_check`
529526 let mut bounds = FxHashSet :: default ( ) ;
530527
@@ -573,11 +570,10 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
573570 ) ;
574571 // The predicate we expect to see. (In our example,
575572 // `Self: 'me`.)
576- let clause = ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives (
577- ty:: OutlivesPredicate ( ty_param, region_param) ,
578- ) ) ;
579- let clause = tcx. mk_predicate ( ty:: Binder :: dummy ( clause) ) ;
580- bounds. insert ( clause) ;
573+ bounds. insert (
574+ ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty_param, region_param) )
575+ . to_predicate ( tcx) ,
576+ ) ;
581577 }
582578 }
583579
@@ -622,11 +618,13 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
622618 } ,
623619 ) ;
624620 // The predicate we expect to see.
625- let clause = ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives (
626- ty:: OutlivesPredicate ( region_a_param, region_b_param) ,
627- ) ) ;
628- let clause = tcx. mk_predicate ( ty:: Binder :: dummy ( clause) ) ;
629- bounds. insert ( clause) ;
621+ bounds. insert (
622+ ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate (
623+ region_a_param,
624+ region_b_param,
625+ ) )
626+ . to_predicate ( tcx) ,
627+ ) ;
630628 }
631629 }
632630 }
@@ -1406,7 +1404,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14061404 infcx,
14071405 wfcx. param_env . without_const ( ) ,
14081406 wfcx. body_def_id ,
1409- p,
1407+ p. as_predicate ( ) ,
14101408 sp,
14111409 )
14121410 } ) ;
@@ -1875,9 +1873,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
18751873 // We lower empty bounds like `Vec<dyn Copy>:` as
18761874 // `WellFormed(Vec<dyn Copy>)`, which will later get checked by
18771875 // regular WF checking
1878- if let ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( ..) ) =
1879- pred. kind ( ) . skip_binder ( )
1880- {
1876+ if let ty:: ClauseKind :: WellFormed ( ..) = pred. kind ( ) . skip_binder ( ) {
18811877 continue ;
18821878 }
18831879 // Match the existing behavior.
0 commit comments