diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-01-30 14:59:19 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-01-31 08:28:28 +1100 |
| commit | 29317604d1926e526ee89d86398ee6d26ef126a4 (patch) | |
| tree | 513eed57be23908f809f6b94acf923394c788333 /compiler/rustc_hir_analysis/src/variance/solve.rs | |
| parent | 4e2ef694f357d527eaa7e5982c914ebb32559b4c (diff) | |
| download | rust-29317604d1926e526ee89d86398ee6d26ef126a4.tar.gz rust-29317604d1926e526ee89d86398ee6d26ef126a4.zip | |
Remove `xform` submodule.
It used to be bigger, with an `Xform` trait, but now it has just a single function.
Diffstat (limited to 'compiler/rustc_hir_analysis/src/variance/solve.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/variance/solve.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/variance/solve.rs b/compiler/rustc_hir_analysis/src/variance/solve.rs index d0bdca86779..4106c1a5b63 100644 --- a/compiler/rustc_hir_analysis/src/variance/solve.rs +++ b/compiler/rustc_hir_analysis/src/variance/solve.rs @@ -12,8 +12,26 @@ use tracing::debug; use super::constraints::*; use super::terms::VarianceTerm::*; use super::terms::*; -use super::xform::*; +fn glb(v1: ty::Variance, v2: ty::Variance) -> ty::Variance { + // Greatest lower bound of the variance lattice as defined in The Paper: + // + // * + // - + + // o + match (v1, v2) { + (ty::Invariant, _) | (_, ty::Invariant) => ty::Invariant, + + (ty::Covariant, ty::Contravariant) => ty::Invariant, + (ty::Contravariant, ty::Covariant) => ty::Invariant, + + (ty::Covariant, ty::Covariant) => ty::Covariant, + + (ty::Contravariant, ty::Contravariant) => ty::Contravariant, + + (x, ty::Bivariant) | (ty::Bivariant, x) => x, + } +} struct SolveContext<'a, 'tcx> { terms_cx: TermsContext<'a, 'tcx>, constraints: Vec<Constraint<'a>>, |
