@@ -97,8 +97,28 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
9797 . intern ( interner) ,
9898 )
9999 }
100- // FIXME(chalk): need to add RegionOutlives/TypeOutlives
101- ty:: PredicateKind :: RegionOutlives ( _) => None ,
100+ ty:: PredicateKind :: RegionOutlives ( predicate) => {
101+ let ( predicate, binders, _named_regions) =
102+ collect_bound_vars ( interner, interner. tcx , predicate) ;
103+
104+ Some (
105+ chalk_ir:: ProgramClauseData :: ForAll ( chalk_ir:: Binders :: new (
106+ binders,
107+ chalk_ir:: ProgramClauseImplication {
108+ consequence : chalk_ir:: DomainGoal :: Holds (
109+ chalk_ir:: WhereClause :: LifetimeOutlives ( chalk_ir:: LifetimeOutlives {
110+ a : predicate. 0 . lower_into ( interner) ,
111+ b : predicate. 1 . lower_into ( interner) ,
112+ } )
113+ ) ,
114+ conditions : chalk_ir:: Goals :: new ( interner) ,
115+ priority : chalk_ir:: ClausePriority :: High ,
116+ } ,
117+ ) )
118+ . intern ( interner) ,
119+ )
120+ } ,
121+ // FIXME(chalk): need to add TypeOutlives
102122 ty:: PredicateKind :: TypeOutlives ( _) => None ,
103123 ty:: PredicateKind :: Projection ( predicate) => {
104124 let ( predicate, binders, _named_regions) =
@@ -156,10 +176,24 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
156176 fn lower_into ( self , interner : & RustInterner < ' tcx > ) -> chalk_ir:: GoalData < RustInterner < ' tcx > > {
157177 match self . kind ( ) {
158178 ty:: PredicateKind :: Trait ( predicate, _) => predicate. lower_into ( interner) ,
159- // FIXME(chalk): we need to register constraints.
160- ty:: PredicateKind :: RegionOutlives ( _predicate) => {
161- chalk_ir:: GoalData :: All ( chalk_ir:: Goals :: new ( interner) )
179+ ty:: PredicateKind :: RegionOutlives ( predicate) => {
180+ let ( predicate, binders, _named_regions) =
181+ collect_bound_vars ( interner, interner. tcx , predicate) ;
182+
183+ chalk_ir:: GoalData :: Quantified (
184+ chalk_ir:: QuantifierKind :: ForAll ,
185+ chalk_ir:: Binders :: new (
186+ binders,
187+ chalk_ir:: GoalData :: DomainGoal ( chalk_ir:: DomainGoal :: Holds (
188+ chalk_ir:: WhereClause :: LifetimeOutlives ( chalk_ir:: LifetimeOutlives {
189+ a : predicate. 0 . lower_into ( interner) ,
190+ b : predicate. 1 . lower_into ( interner) ,
191+ } )
192+ ) ) . intern ( interner)
193+ )
194+ )
162195 }
196+ // FIXME(chalk): TypeOutlives
163197 ty:: PredicateKind :: TypeOutlives ( _predicate) => {
164198 chalk_ir:: GoalData :: All ( chalk_ir:: Goals :: new ( interner) )
165199 }
@@ -182,12 +216,15 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
182216 GenericArgKind :: Lifetime ( lt) => bug ! ( "unexpect well formed predicate: {:?}" , lt) ,
183217 } ,
184218
219+ ty:: PredicateKind :: ObjectSafe ( t) => {
220+ chalk_ir:: GoalData :: DomainGoal ( chalk_ir:: DomainGoal :: ObjectSafe ( chalk_ir:: TraitId ( * t) ) )
221+ }
222+
185223 // FIXME(chalk): other predicates
186224 //
187225 // We can defer this, but ultimately we'll want to express
188226 // some of these in terms of chalk operations.
189- ty:: PredicateKind :: ObjectSafe ( ..)
190- | ty:: PredicateKind :: ClosureKind ( ..)
227+ ty:: PredicateKind :: ClosureKind ( ..)
191228 | ty:: PredicateKind :: Subtype ( ..)
192229 | ty:: PredicateKind :: ConstEvaluatable ( ..)
193230 | ty:: PredicateKind :: ConstEquate ( ..) => {
@@ -484,7 +521,19 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
484521 chalk_ir:: WhereClause :: Implemented ( predicate. trait_ref . lower_into ( interner) ) ,
485522 ) )
486523 }
487- ty:: PredicateKind :: RegionOutlives ( _predicate) => None ,
524+ ty:: PredicateKind :: RegionOutlives ( predicate) => {
525+ let ( predicate, binders, _named_regions) =
526+ collect_bound_vars ( interner, interner. tcx , predicate) ;
527+
528+ Some ( chalk_ir:: Binders :: new (
529+ binders,
530+ chalk_ir:: WhereClause :: LifetimeOutlives ( chalk_ir:: LifetimeOutlives {
531+ a : predicate. 0 . lower_into ( interner) ,
532+ b : predicate. 1 . lower_into ( interner) ,
533+ } ) ,
534+ ) )
535+
536+ } ,
488537 ty:: PredicateKind :: TypeOutlives ( _predicate) => None ,
489538 ty:: PredicateKind :: Projection ( _predicate) => None ,
490539 ty:: PredicateKind :: WellFormed ( _ty) => None ,
0 commit comments