@@ -116,6 +116,8 @@ impl context::Context for ChalkArenas<'tcx> {
116116
117117 type UnificationResult = UnificationResult < ' tcx > ;
118118
119+ type Variance = ty:: Variance ;
120+
119121 fn goal_in_environment (
120122 env : & Environment < ' tcx > ,
121123 goal : Goal < ' tcx > ,
@@ -332,6 +334,11 @@ impl context::InferenceTable<ChalkArenas<'gcx>, ChalkArenas<'tcx>>
332334 GoalKind :: DomainGoal ( d) => HhGoal :: DomainGoal ( d) ,
333335 GoalKind :: Quantified ( QuantifierKind :: Universal , binder) => HhGoal :: ForAll ( binder) ,
334336 GoalKind :: Quantified ( QuantifierKind :: Existential , binder) => HhGoal :: Exists ( binder) ,
337+ GoalKind :: Subtype ( a, b) => HhGoal :: Unify (
338+ ty:: Variance :: Covariant ,
339+ a. into ( ) ,
340+ b. into ( )
341+ ) ,
335342 GoalKind :: CannotProve => HhGoal :: CannotProve ,
336343 }
337344 }
@@ -444,11 +451,13 @@ impl context::UnificationOps<ChalkArenas<'gcx>, ChalkArenas<'tcx>>
444451 fn unify_parameters (
445452 & mut self ,
446453 environment : & Environment < ' tcx > ,
454+ variance : ty:: Variance ,
447455 a : & Kind < ' tcx > ,
448456 b : & Kind < ' tcx > ,
449457 ) -> Fallible < UnificationResult < ' tcx > > {
450458 self . infcx . commit_if_ok ( |_| {
451- unify ( self . infcx , * environment, a, b) . map_err ( |_| chalk_engine:: fallible:: NoSolution )
459+ unify ( self . infcx , * environment, variance, a, b)
460+ . map_err ( |_| chalk_engine:: fallible:: NoSolution )
452461 } )
453462 }
454463
@@ -673,6 +682,13 @@ crate fn evaluate_goal<'a, 'tcx>(
673682 GoalKind :: DomainGoal ( DomainGoal :: WellFormed ( WellFormed :: Ty ( ty) ) )
674683 ) ,
675684
685+ ty:: Predicate :: Subtype ( predicate) => tcx. mk_goal (
686+ GoalKind :: Quantified (
687+ QuantifierKind :: Universal ,
688+ predicate. map_bound ( |pred| tcx. mk_goal ( GoalKind :: Subtype ( pred. a , pred. b ) ) )
689+ )
690+ ) ,
691+
676692 other => tcx. mk_goal (
677693 GoalKind :: from_poly_domain_goal ( other. lower ( ) , tcx)
678694 ) ,
0 commit comments