Nit: improve Binders comment in `relate_tys`

This commit is contained in:
Niko Matsakis 2018-07-25 16:38:50 +03:00
parent d85a7da8fe
commit 3171cbe986
1 changed files with 10 additions and 8 deletions

View File

@ -410,11 +410,11 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
);
if self.ambient_covariance() {
// Covariance, so we want `for<'a> A <: for<'b...> B` --
// therefore we replace all of the `'b...` regions with
// placeholders and then replace `'a...` with
// existentials. We then check if any instantiation of A
// can match against the placeholders in B.
// Covariance, so we want `for<..> A <: for<..> B` --
// therefore we compare any instantiation of A (i.e., A
// instantiated with existentials) against every
// instantiation of B (i.e., B instantiated with
// universals).
let b_scope = self.create_scope(b, UniversallyQuantified(true));
let a_scope = self.create_scope(a, UniversallyQuantified(false));
@ -443,9 +443,11 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
}
if self.ambient_contravariance() {
// Contravariance, so we want `for<'a> A :> for<'b...> B`
// -- do the opposite, therefore, of covariant. Replace
// the `'a...` placeholders with `'b...` variables.
// Contravariance, so we want `for<..> A :> for<..> B`
// -- therefore we compare every instantiation of A (i.e.,
// A instantiated with universals) against any
// instantiation of B (i.e., B instantiated with
// existentials). Opposite of above.
let a_scope = self.create_scope(a, UniversallyQuantified(true));
let b_scope = self.create_scope(b, UniversallyQuantified(false));