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;
2727
2828pub ( crate ) mod dump;
2929
30- /// Code for transforming variances.
31- mod xform;
32-
3330pub ( crate ) fn provide ( providers : & mut Providers ) {
3431 * providers = Providers { variances_of, crate_variances, ..* providers } ;
3532}
Original file line number Diff line number Diff line change @@ -12,8 +12,26 @@ use tracing::debug;
1212use super :: constraints:: * ;
1313use super :: terms:: VarianceTerm :: * ;
1414use super :: terms:: * ;
15- use super :: xform:: * ;
1615
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+ }
1735struct SolveContext < ' a , ' tcx > {
1836 terms_cx : TermsContext < ' a , ' tcx > ,
1937 constraints : Vec < Constraint < ' a > > ,
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments