Skip to content

Commit

Permalink
Remove xform submodule.
Browse files Browse the repository at this point in the history
It used to be bigger, with an `Xform` trait, but now it has just a
single function.
  • Loading branch information
nnethercote committed Jan 30, 2025
1 parent 556e08f commit 7bf9671
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_hir_analysis/src/variance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ mod solve;

pub(crate) mod dump;

/// Code for transforming variances.
mod xform;

pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { variances_of, crate_variances, ..*providers };
}
Expand Down
20 changes: 19 additions & 1 deletion compiler/rustc_hir_analysis/src/variance/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand Down
22 changes: 0 additions & 22 deletions compiler/rustc_hir_analysis/src/variance/xform.rs

This file was deleted.

0 comments on commit 7bf9671

Please sign in to comment.