This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-26
lines changed
compiler/rustc_hir_analysis/src/variance Expand file tree Collapse file tree 3 files changed +19
-26
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,6 @@ mod solve;
27
27
28
28
pub ( crate ) mod dump;
29
29
30
- /// Code for transforming variances.
31
- mod xform;
32
-
33
30
pub ( crate ) fn provide ( providers : & mut Providers ) {
34
31
* providers = Providers { variances_of, crate_variances, ..* providers } ;
35
32
}
Original file line number Diff line number Diff line change @@ -12,8 +12,26 @@ use tracing::debug;
12
12
use super :: constraints:: * ;
13
13
use super :: terms:: VarianceTerm :: * ;
14
14
use super :: terms:: * ;
15
- use super :: xform:: * ;
16
15
16
+ fn glb ( v1 : ty:: Variance , v2 : ty:: Variance ) -> ty:: Variance {
17
+ // Greatest lower bound of the variance lattice as defined in The Paper:
18
+ //
19
+ // *
20
+ // - +
21
+ // o
22
+ match ( v1, v2) {
23
+ ( ty:: Invariant , _) | ( _, ty:: Invariant ) => ty:: Invariant ,
24
+
25
+ ( ty:: Covariant , ty:: Contravariant ) => ty:: Invariant ,
26
+ ( ty:: Contravariant , ty:: Covariant ) => ty:: Invariant ,
27
+
28
+ ( ty:: Covariant , ty:: Covariant ) => ty:: Covariant ,
29
+
30
+ ( ty:: Contravariant , ty:: Contravariant ) => ty:: Contravariant ,
31
+
32
+ ( x, ty:: Bivariant ) | ( ty:: Bivariant , x) => x,
33
+ }
34
+ }
17
35
struct SolveContext < ' a , ' tcx > {
18
36
terms_cx : TermsContext < ' a , ' tcx > ,
19
37
constraints : Vec < Constraint < ' a > > ,
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments