Skip to content

Commit 2931760

Browse files
committed
Remove xform submodule.
It used to be bigger, with an `Xform` trait, but now it has just a single function.
1 parent 4e2ef69 commit 2931760

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

compiler/rustc_hir_analysis/src/variance/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ mod solve;
2727

2828
pub(crate) mod dump;
2929

30-
/// Code for transforming variances.
31-
mod xform;
32-
3330
pub(crate) fn provide(providers: &mut Providers) {
3431
*providers = Providers { variances_of, crate_variances, ..*providers };
3532
}

compiler/rustc_hir_analysis/src/variance/solve.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,26 @@ use tracing::debug;
1212
use super::constraints::*;
1313
use super::terms::VarianceTerm::*;
1414
use 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+
}
1735
struct SolveContext<'a, 'tcx> {
1836
terms_cx: TermsContext<'a, 'tcx>,
1937
constraints: Vec<Constraint<'a>>,

compiler/rustc_hir_analysis/src/variance/xform.rs

-22
This file was deleted.

0 commit comments

Comments
 (0)