Skip to content

Commit 3171cbe

Browse files
committed
Nit: improve Binders comment in relate_tys
1 parent d85a7da commit 3171cbe

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,11 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
410410
);
411411

412412
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).
418418

419419
let b_scope = self.create_scope(b, UniversallyQuantified(true));
420420
let a_scope = self.create_scope(a, UniversallyQuantified(false));
@@ -443,9 +443,11 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
443443
}
444444

445445
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.
449451

450452
let a_scope = self.create_scope(a, UniversallyQuantified(true));
451453
let b_scope = self.create_scope(b, UniversallyQuantified(false));

0 commit comments

Comments
 (0)