Skip to content

Commit 0aab101

Browse files
committed
Merge rustc_infer::infer::relate::{glb,lub}.
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.
1 parent 7042c26 commit 0aab101

File tree

5 files changed

+196
-333
lines changed

5 files changed

+196
-333
lines changed

compiler/rustc_infer/src/infer/relate/combine.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! There are four type combiners: [TypeRelating], [Lub], and [Glb],
1+
//! There are four type combiners: [TypeRelating], `Lub`, and `Glb`,
22
//! and `NllTypeRelating` in rustc_borrowck, which is only used for NLL.
33
//!
44
//! Each implements the trait [TypeRelation] and contains methods for
@@ -26,8 +26,7 @@ use rustc_middle::ty::{self, InferConst, IntType, Ty, TyCtxt, TypeVisitableExt,
2626
pub use rustc_next_trait_solver::relate::combine::*;
2727
use tracing::debug;
2828

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

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

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

309308
pub fn register_obligations(

compiler/rustc_infer/src/infer/relate/glb.rs

-159
This file was deleted.

0 commit comments

Comments
 (0)