Remove xform
submodule.
It used to be bigger, with an `Xform` trait, but now it has just a single function.
This commit is contained in:
parent
4e2ef694f3
commit
29317604d1
3 changed files with 19 additions and 26 deletions
|
@ -27,9 +27,6 @@ mod solve;
|
||||||
|
|
||||||
pub(crate) mod dump;
|
pub(crate) mod dump;
|
||||||
|
|
||||||
/// Code for transforming variances.
|
|
||||||
mod xform;
|
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers { variances_of, crate_variances, ..*providers };
|
*providers = Providers { variances_of, crate_variances, ..*providers };
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,26 @@ use tracing::debug;
|
||||||
use super::constraints::*;
|
use super::constraints::*;
|
||||||
use super::terms::VarianceTerm::*;
|
use super::terms::VarianceTerm::*;
|
||||||
use super::terms::*;
|
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> {
|
struct SolveContext<'a, 'tcx> {
|
||||||
terms_cx: TermsContext<'a, 'tcx>,
|
terms_cx: TermsContext<'a, 'tcx>,
|
||||||
constraints: Vec<Constraint<'a>>,
|
constraints: Vec<Constraint<'a>>,
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
use rustc_middle::ty;
|
|
||||||
|
|
||||||
pub(crate) 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,
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue