@@ -50,14 +50,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
50
50
locations : Locations ,
51
51
category : ConstraintCategory < ' tcx > ,
52
52
) -> 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) ?;
61
55
Ok ( ( ) )
62
56
}
63
57
}
@@ -106,15 +100,15 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
106
100
107
101
fn ambient_covariance ( & self ) -> bool {
108
102
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 ,
111
105
}
112
106
}
113
107
114
108
fn ambient_contravariance ( & self ) -> bool {
115
109
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 ,
118
112
}
119
113
}
120
114
@@ -336,11 +330,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
336
330
337
331
debug ! ( ?self . ambient_variance) ;
338
332
// 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) } ;
344
334
345
335
self . ambient_variance = old_ambient_variance;
346
336
@@ -474,7 +464,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
474
464
}
475
465
476
466
match self . ambient_variance {
477
- ty:: Variance :: Covariant => {
467
+ ty:: Covariant => {
478
468
// Covariance, so we want `for<..> A <: for<..> B` --
479
469
// therefore we compare any instantiation of A (i.e., A
480
470
// instantiated with existentials) against every
@@ -489,7 +479,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
489
479
} ) ?;
490
480
}
491
481
492
- ty:: Variance :: Contravariant => {
482
+ ty:: Contravariant => {
493
483
// Contravariance, so we want `for<..> A :> for<..> B` --
494
484
// therefore we compare every instantiation of A (i.e., A
495
485
// instantiated with universals) against any
@@ -504,7 +494,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
504
494
} ) ?;
505
495
}
506
496
507
- ty:: Variance :: Invariant => {
497
+ ty:: Invariant => {
508
498
// Invariant, so we want `for<..> A == for<..> B` --
509
499
// therefore we want `exists<..> A == for<..> B` and
510
500
// `exists<..> B == for<..> A`.
@@ -525,7 +515,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
525
515
} ) ?;
526
516
}
527
517
528
- ty:: Variance :: Bivariant => { }
518
+ ty:: Bivariant => { }
529
519
}
530
520
531
521
Ok ( a)
@@ -584,23 +574,23 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx,
584
574
585
575
fn register_alias_relate_predicate ( & mut self , a : Ty < ' tcx > , b : Ty < ' tcx > ) {
586
576
self . register_predicates ( [ ty:: Binder :: dummy ( match self . ambient_variance {
587
- ty:: Variance :: Covariant => ty:: PredicateKind :: AliasRelate (
577
+ ty:: Covariant => ty:: PredicateKind :: AliasRelate (
588
578
a. into ( ) ,
589
579
b. into ( ) ,
590
580
ty:: AliasRelationDirection :: Subtype ,
591
581
) ,
592
582
// a :> b is b <: a
593
- ty:: Variance :: Contravariant => ty:: PredicateKind :: AliasRelate (
583
+ ty:: Contravariant => ty:: PredicateKind :: AliasRelate (
594
584
b. into ( ) ,
595
585
a. into ( ) ,
596
586
ty:: AliasRelationDirection :: Subtype ,
597
587
) ,
598
- ty:: Variance :: Invariant => ty:: PredicateKind :: AliasRelate (
588
+ ty:: Invariant => ty:: PredicateKind :: AliasRelate (
599
589
a. into ( ) ,
600
590
b. into ( ) ,
601
591
ty:: AliasRelationDirection :: Equate ,
602
592
) ,
603
- ty:: Variance :: Bivariant => {
593
+ ty:: Bivariant => {
604
594
unreachable ! ( "cannot defer an alias-relate goal with Bivariant variance (yet?)" )
605
595
}
606
596
} ) ] ) ;
0 commit comments