@@ -15,7 +15,7 @@ use rustc_middle::mir::ConstraintCategory;
15
15
use rustc_middle:: query:: Providers ;
16
16
use rustc_middle:: ty:: trait_def:: TraitSpecializationKind ;
17
17
use rustc_middle:: ty:: {
18
- self , AdtKind , GenericParamDefKind , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
18
+ self , AdtKind , GenericParamDefKind , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
19
19
TypeVisitable , TypeVisitableExt , TypeVisitor ,
20
20
} ;
21
21
use rustc_middle:: ty:: { GenericArgKind , InternalSubsts } ;
@@ -322,7 +322,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
322
322
// Gather the bounds with which all other items inside of this trait constrain the GAT.
323
323
// This is calculated by taking the intersection of the bounds that each item
324
324
// 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 ;
326
326
for item in associated_items {
327
327
let item_def_id = item. id . owner_id ;
328
328
// 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
419
419
let mut unsatisfied_bounds: Vec < _ > = required_bounds
420
420
. into_iter ( )
421
421
. 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 (
436
433
tcx,
437
434
gat_def_id. def_id ,
438
435
param_env,
439
436
& FxIndexSet :: default ( ) ,
440
437
a,
441
438
b,
442
439
) ,
443
- _ => bug ! ( "Unexpected PredicateKind " ) ,
440
+ _ => bug ! ( "Unexpected ClauseKind " ) ,
444
441
} )
445
442
. map ( |clause| clause. to_string ( ) )
446
443
. collect ( ) ;
@@ -488,7 +485,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
488
485
fn augment_param_env < ' tcx > (
489
486
tcx : TyCtxt < ' tcx > ,
490
487
param_env : ty:: ParamEnv < ' tcx > ,
491
- new_predicates : Option < & FxHashSet < ty:: Predicate < ' tcx > > > ,
488
+ new_predicates : Option < & FxHashSet < ty:: Clause < ' tcx > > > ,
492
489
) -> ty:: ParamEnv < ' tcx > {
493
490
let Some ( new_predicates) = new_predicates else {
494
491
return param_env;
@@ -498,7 +495,7 @@ fn augment_param_env<'tcx>(
498
495
return param_env;
499
496
}
500
497
501
- let bounds = tcx. mk_predicates_from_iter (
498
+ let bounds = tcx. mk_clauses_from_iter (
502
499
param_env. caller_bounds ( ) . iter ( ) . chain ( new_predicates. iter ( ) . cloned ( ) ) ,
503
500
) ;
504
501
// FIXME(compiler-errors): Perhaps there is a case where we need to normalize this
@@ -524,7 +521,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
524
521
wf_tys : & FxIndexSet < Ty < ' tcx > > ,
525
522
gat_def_id : LocalDefId ,
526
523
gat_generics : & ' tcx ty:: Generics ,
527
- ) -> Option < FxHashSet < ty:: Predicate < ' tcx > > > {
524
+ ) -> Option < FxHashSet < ty:: Clause < ' tcx > > > {
528
525
// The bounds we that we would require from `to_check`
529
526
let mut bounds = FxHashSet :: default ( ) ;
530
527
@@ -573,11 +570,10 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
573
570
) ;
574
571
// The predicate we expect to see. (In our example,
575
572
// `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
+ ) ;
581
577
}
582
578
}
583
579
@@ -622,11 +618,13 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
622
618
} ,
623
619
) ;
624
620
// 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
+ ) ;
630
628
}
631
629
}
632
630
}
@@ -1406,7 +1404,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
1406
1404
infcx,
1407
1405
wfcx. param_env . without_const ( ) ,
1408
1406
wfcx. body_def_id ,
1409
- p,
1407
+ p. as_predicate ( ) ,
1410
1408
sp,
1411
1409
)
1412
1410
} ) ;
@@ -1875,9 +1873,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
1875
1873
// We lower empty bounds like `Vec<dyn Copy>:` as
1876
1874
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by
1877
1875
// 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 ( ) {
1881
1877
continue ;
1882
1878
}
1883
1879
// Match the existing behavior.
0 commit comments