Skip to content

Commit

Permalink
Merge rustc_infer::infer::relate::{glb,lub}.
Browse files Browse the repository at this point in the history
Most of the code in these two modules is duplicated in the other module.
This commit eliminates the duplication by replacing them with a new
module `lattice_op`. The new `LatticeOpKind` enum is used to distinguish
between glb and lub in the few places where the behaviour differs.
  • Loading branch information
nnethercote committed Oct 3, 2024
1 parent 7042c26 commit 0aab101
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 333 deletions.
13 changes: 6 additions & 7 deletions compiler/rustc_infer/src/infer/relate/combine.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! There are four type combiners: [TypeRelating], [Lub], and [Glb],
//! There are four type combiners: [TypeRelating], `Lub`, and `Glb`,
//! and `NllTypeRelating` in rustc_borrowck, which is only used for NLL.
//!
//! Each implements the trait [TypeRelation] and contains methods for
Expand Down Expand Up @@ -26,8 +26,7 @@ use rustc_middle::ty::{self, InferConst, IntType, Ty, TyCtxt, TypeVisitableExt,
pub use rustc_next_trait_solver::relate::combine::*;
use tracing::debug;

use super::glb::Glb;
use super::lub::Lub;
use super::lattice::{LatticeOp, LatticeOpKind};
use super::type_relating::TypeRelating;
use super::{RelateResult, StructurallyRelateAliases};
use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace, relate};
Expand Down Expand Up @@ -298,12 +297,12 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Contravariant)
}

pub fn lub<'a>(&'a mut self) -> Lub<'a, 'infcx, 'tcx> {
Lub::new(self)
pub(crate) fn lub<'a>(&'a mut self) -> LatticeOp<'a, 'infcx, 'tcx> {
LatticeOp::new(self, LatticeOpKind::Lub)
}

pub fn glb<'a>(&'a mut self) -> Glb<'a, 'infcx, 'tcx> {
Glb::new(self)
pub(crate) fn glb<'a>(&'a mut self) -> LatticeOp<'a, 'infcx, 'tcx> {
LatticeOp::new(self, LatticeOpKind::Glb)
}

pub fn register_obligations(
Expand Down
159 changes: 0 additions & 159 deletions compiler/rustc_infer/src/infer/relate/glb.rs

This file was deleted.

Loading

0 comments on commit 0aab101

Please sign in to comment.