@@ -50,14 +50,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
5050 locations : Locations ,
5151 category : ConstraintCategory < ' tcx > ,
5252 ) -> Result < ( ) , NoSolution > {
53- NllTypeRelating :: new (
54- self ,
55- locations,
56- category,
57- UniverseInfo :: other ( ) ,
58- ty:: Variance :: Invariant ,
59- )
60- . relate ( a, b) ?;
53+ NllTypeRelating :: new ( self , locations, category, UniverseInfo :: other ( ) , ty:: Invariant )
54+ . relate ( a, b) ?;
6155 Ok ( ( ) )
6256 }
6357}
@@ -106,15 +100,15 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
106100
107101 fn ambient_covariance ( & self ) -> bool {
108102 match self . ambient_variance {
109- ty:: Variance :: Covariant | ty:: Variance :: Invariant => true ,
110- ty:: Variance :: Contravariant | ty:: Variance :: Bivariant => false ,
103+ ty:: Covariant | ty:: Invariant => true ,
104+ ty:: Contravariant | ty:: Bivariant => false ,
111105 }
112106 }
113107
114108 fn ambient_contravariance ( & self ) -> bool {
115109 match self . ambient_variance {
116- ty:: Variance :: Contravariant | ty:: Variance :: Invariant => true ,
117- ty:: Variance :: Covariant | ty:: Variance :: Bivariant => false ,
110+ ty:: Contravariant | ty:: Invariant => true ,
111+ ty:: Covariant | ty:: Bivariant => false ,
118112 }
119113 }
120114
@@ -336,11 +330,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
336330
337331 debug ! ( ?self . ambient_variance) ;
338332 // In a bivariant context this always succeeds.
339- let r = if self . ambient_variance == ty:: Variance :: Bivariant {
340- Ok ( a)
341- } else {
342- self . relate ( a, b)
343- } ;
333+ let r = if self . ambient_variance == ty:: Bivariant { Ok ( a) } else { self . relate ( a, b) } ;
344334
345335 self . ambient_variance = old_ambient_variance;
346336
@@ -474,7 +464,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
474464 }
475465
476466 match self . ambient_variance {
477- ty:: Variance :: Covariant => {
467+ ty:: Covariant => {
478468 // Covariance, so we want `for<..> A <: for<..> B` --
479469 // therefore we compare any instantiation of A (i.e., A
480470 // instantiated with existentials) against every
@@ -489,7 +479,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
489479 } ) ?;
490480 }
491481
492- ty:: Variance :: Contravariant => {
482+ ty:: Contravariant => {
493483 // Contravariance, so we want `for<..> A :> for<..> B` --
494484 // therefore we compare every instantiation of A (i.e., A
495485 // instantiated with universals) against any
@@ -504,7 +494,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
504494 } ) ?;
505495 }
506496
507- ty:: Variance :: Invariant => {
497+ ty:: Invariant => {
508498 // Invariant, so we want `for<..> A == for<..> B` --
509499 // therefore we want `exists<..> A == for<..> B` and
510500 // `exists<..> B == for<..> A`.
@@ -525,7 +515,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
525515 } ) ?;
526516 }
527517
528- ty:: Variance :: Bivariant => { }
518+ ty:: Bivariant => { }
529519 }
530520
531521 Ok ( a)
@@ -584,23 +574,23 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx,
584574
585575 fn register_alias_relate_predicate ( & mut self , a : Ty < ' tcx > , b : Ty < ' tcx > ) {
586576 self . register_predicates ( [ ty:: Binder :: dummy ( match self . ambient_variance {
587- ty:: Variance :: Covariant => ty:: PredicateKind :: AliasRelate (
577+ ty:: Covariant => ty:: PredicateKind :: AliasRelate (
588578 a. into ( ) ,
589579 b. into ( ) ,
590580 ty:: AliasRelationDirection :: Subtype ,
591581 ) ,
592582 // a :> b is b <: a
593- ty:: Variance :: Contravariant => ty:: PredicateKind :: AliasRelate (
583+ ty:: Contravariant => ty:: PredicateKind :: AliasRelate (
594584 b. into ( ) ,
595585 a. into ( ) ,
596586 ty:: AliasRelationDirection :: Subtype ,
597587 ) ,
598- ty:: Variance :: Invariant => ty:: PredicateKind :: AliasRelate (
588+ ty:: Invariant => ty:: PredicateKind :: AliasRelate (
599589 a. into ( ) ,
600590 b. into ( ) ,
601591 ty:: AliasRelationDirection :: Equate ,
602592 ) ,
603- ty:: Variance :: Bivariant => {
593+ ty:: Bivariant => {
604594 unreachable ! ( "cannot defer an alias-relate goal with Bivariant variance (yet?)" )
605595 }
606596 } ) ] ) ;
0 commit comments