@@ -97,8 +97,28 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
97
97
. intern ( interner) ,
98
98
)
99
99
}
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
102
122
ty:: PredicateKind :: TypeOutlives ( _) => None ,
103
123
ty:: PredicateKind :: Projection ( predicate) => {
104
124
let ( predicate, binders, _named_regions) =
@@ -156,10 +176,24 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
156
176
fn lower_into ( self , interner : & RustInterner < ' tcx > ) -> chalk_ir:: GoalData < RustInterner < ' tcx > > {
157
177
match self . kind ( ) {
158
178
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
+ )
162
195
}
196
+ // FIXME(chalk): TypeOutlives
163
197
ty:: PredicateKind :: TypeOutlives ( _predicate) => {
164
198
chalk_ir:: GoalData :: All ( chalk_ir:: Goals :: new ( interner) )
165
199
}
@@ -182,12 +216,15 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
182
216
GenericArgKind :: Lifetime ( lt) => bug ! ( "unexpect well formed predicate: {:?}" , lt) ,
183
217
} ,
184
218
219
+ ty:: PredicateKind :: ObjectSafe ( t) => {
220
+ chalk_ir:: GoalData :: DomainGoal ( chalk_ir:: DomainGoal :: ObjectSafe ( chalk_ir:: TraitId ( * t) ) )
221
+ }
222
+
185
223
// FIXME(chalk): other predicates
186
224
//
187
225
// We can defer this, but ultimately we'll want to express
188
226
// some of these in terms of chalk operations.
189
- ty:: PredicateKind :: ObjectSafe ( ..)
190
- | ty:: PredicateKind :: ClosureKind ( ..)
227
+ ty:: PredicateKind :: ClosureKind ( ..)
191
228
| ty:: PredicateKind :: Subtype ( ..)
192
229
| ty:: PredicateKind :: ConstEvaluatable ( ..)
193
230
| ty:: PredicateKind :: ConstEquate ( ..) => {
@@ -484,7 +521,19 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
484
521
chalk_ir:: WhereClause :: Implemented ( predicate. trait_ref . lower_into ( interner) ) ,
485
522
) )
486
523
}
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
+ } ,
488
537
ty:: PredicateKind :: TypeOutlives ( _predicate) => None ,
489
538
ty:: PredicateKind :: Projection ( _predicate) => None ,
490
539
ty:: PredicateKind :: WellFormed ( _ty) => None ,
0 commit comments