@@ -535,6 +535,17 @@ impl<'tcx> Predicate<'tcx> {
535535 self
536536 }
537537
538+ #[ instrument( level = "debug" , skip( tcx) , ret) ]
539+ pub fn is_coinductive ( self , tcx : TyCtxt < ' tcx > ) -> bool {
540+ match self . kind ( ) . skip_binder ( ) {
541+ ty:: PredicateKind :: Clause ( ty:: Clause :: Trait ( data) ) => {
542+ tcx. trait_is_coinductive ( data. def_id ( ) )
543+ }
544+ ty:: PredicateKind :: WellFormed ( _) => true ,
545+ _ => false ,
546+ }
547+ }
548+
538549 /// Whether this projection can be soundly normalized.
539550 ///
540551 /// Wf predicates must not be normalized, as normalization
@@ -1018,6 +1029,24 @@ pub struct ProjectionPredicate<'tcx> {
10181029 pub term : Term < ' tcx > ,
10191030}
10201031
1032+ impl < ' tcx > ProjectionPredicate < ' tcx > {
1033+ pub fn self_ty ( self ) -> Ty < ' tcx > {
1034+ self . projection_ty . self_ty ( )
1035+ }
1036+
1037+ pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> ProjectionPredicate < ' tcx > {
1038+ Self { projection_ty : self . projection_ty . with_self_ty ( tcx, self_ty) , ..self }
1039+ }
1040+
1041+ pub fn trait_def_id ( self , tcx : TyCtxt < ' tcx > ) -> DefId {
1042+ self . projection_ty . trait_def_id ( tcx)
1043+ }
1044+
1045+ pub fn def_id ( self ) -> DefId {
1046+ self . projection_ty . def_id
1047+ }
1048+ }
1049+
10211050pub type PolyProjectionPredicate < ' tcx > = Binder < ' tcx , ProjectionPredicate < ' tcx > > ;
10221051
10231052impl < ' tcx > PolyProjectionPredicate < ' tcx > {
@@ -1054,18 +1083,6 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
10541083 }
10551084}
10561085
1057- impl < ' tcx > ProjectionPredicate < ' tcx > {
1058- pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
1059- Self {
1060- projection_ty : tcx. mk_alias_ty (
1061- self . projection_ty . def_id ,
1062- [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . projection_ty . substs . iter ( ) . skip ( 1 ) ) ,
1063- ) ,
1064- ..self
1065- }
1066- }
1067- }
1068-
10691086pub trait ToPolyTraitRef < ' tcx > {
10701087 fn to_poly_trait_ref ( & self ) -> PolyTraitRef < ' tcx > ;
10711088}
0 commit comments