@@ -535,6 +535,17 @@ impl<'tcx> Predicate<'tcx> {
535
535
self
536
536
}
537
537
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
+
538
549
/// Whether this projection can be soundly normalized.
539
550
///
540
551
/// Wf predicates must not be normalized, as normalization
@@ -1018,6 +1029,24 @@ pub struct ProjectionPredicate<'tcx> {
1018
1029
pub term : Term < ' tcx > ,
1019
1030
}
1020
1031
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
+
1021
1050
pub type PolyProjectionPredicate < ' tcx > = Binder < ' tcx , ProjectionPredicate < ' tcx > > ;
1022
1051
1023
1052
impl < ' tcx > PolyProjectionPredicate < ' tcx > {
@@ -1054,18 +1083,6 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
1054
1083
}
1055
1084
}
1056
1085
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
-
1069
1086
pub trait ToPolyTraitRef < ' tcx > {
1070
1087
fn to_poly_trait_ref ( & self ) -> PolyTraitRef < ' tcx > ;
1071
1088
}
0 commit comments