@@ -410,11 +410,11 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
410
410
) ;
411
411
412
412
if self . ambient_covariance ( ) {
413
- // Covariance, so we want `for<'a > A <: for<'b. ..> B` --
414
- // therefore we replace all of the `'b...` regions with
415
- // placeholders and then replace `'a...` with
416
- // existentials. We then check if any instantiation of A
417
- // can match against the placeholders in B .
413
+ // Covariance, so we want `for<.. > A <: for<..> B` --
414
+ // therefore we compare any instantiation of A (i.e., A
415
+ // instantiated with existentials) against every
416
+ // instantiation of B (i.e., B instantiated with
417
+ // universals) .
418
418
419
419
let b_scope = self . create_scope ( b, UniversallyQuantified ( true ) ) ;
420
420
let a_scope = self . create_scope ( a, UniversallyQuantified ( false ) ) ;
@@ -443,9 +443,11 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
443
443
}
444
444
445
445
if self . ambient_contravariance ( ) {
446
- // Contravariance, so we want `for<'a> A :> for<'b...> B`
447
- // -- do the opposite, therefore, of covariant. Replace
448
- // the `'a...` placeholders with `'b...` variables.
446
+ // Contravariance, so we want `for<..> A :> for<..> B`
447
+ // -- therefore we compare every instantiation of A (i.e.,
448
+ // A instantiated with universals) against any
449
+ // instantiation of B (i.e., B instantiated with
450
+ // existentials). Opposite of above.
449
451
450
452
let a_scope = self . create_scope ( a, UniversallyQuantified ( true ) ) ;
451
453
let b_scope = self . create_scope ( b, UniversallyQuantified ( false ) ) ;
0 commit comments