|
1 |
| -//! There are four type combiners: [Equate], [Sub], [Lub], and [Glb]. |
| 1 | +//! There are four type combiners: [TypeRelating], [Lub], and [Glb], |
| 2 | +//! and `NllTypeRelating` in rustc_borrowck, which is only used for NLL. |
| 3 | +//! |
2 | 4 | //! Each implements the trait [TypeRelation] and contains methods for
|
3 | 5 | //! combining two instances of various things and yielding a new instance.
|
4 | 6 | //! These combiner methods always yield a `Result<T>`. To relate two
|
|
22 | 24 | //! [TypeRelation::a_is_expected], so when dealing with contravariance
|
23 | 25 | //! this should be correctly updated.
|
24 | 26 |
|
25 |
| -use super::equate::Equate; |
26 | 27 | use super::glb::Glb;
|
27 | 28 | use super::lub::Lub;
|
28 |
| -use super::sub::Sub; |
| 29 | +use super::type_relating::TypeRelating; |
29 | 30 | use super::StructurallyRelateAliases;
|
30 | 31 | use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace};
|
31 | 32 | use crate::traits::{Obligation, PredicateObligations};
|
@@ -322,12 +323,12 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
322 | 323 | &'a mut self,
|
323 | 324 | structurally_relate_aliases: StructurallyRelateAliases,
|
324 | 325 | a_is_expected: bool,
|
325 |
| - ) -> Equate<'a, 'infcx, 'tcx> { |
326 |
| - Equate::new(self, structurally_relate_aliases, a_is_expected) |
| 326 | + ) -> TypeRelating<'a, 'infcx, 'tcx> { |
| 327 | + TypeRelating::new(self, a_is_expected, structurally_relate_aliases, ty::Invariant) |
327 | 328 | }
|
328 | 329 |
|
329 |
| - pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'tcx> { |
330 |
| - Sub::new(self, a_is_expected) |
| 330 | + pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> TypeRelating<'a, 'infcx, 'tcx> { |
| 331 | + TypeRelating::new(self, a_is_expected, StructurallyRelateAliases::No, ty::Covariant) |
331 | 332 | }
|
332 | 333 |
|
333 | 334 | pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'tcx> {
|
@@ -367,19 +368,8 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
|
367 | 368 | /// be used if control over the obligation causes is required.
|
368 | 369 | fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>);
|
369 | 370 |
|
370 |
| - /// Register an obligation that both types must be related to each other according to |
371 |
| - /// the [`ty::AliasRelationDirection`] given by [`ObligationEmittingRelation::alias_relate_direction`] |
372 |
| - fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) { |
373 |
| - self.register_predicates([ty::Binder::dummy(ty::PredicateKind::AliasRelate( |
374 |
| - a.into(), |
375 |
| - b.into(), |
376 |
| - self.alias_relate_direction(), |
377 |
| - ))]); |
378 |
| - } |
379 |
| - |
380 |
| - /// Relation direction emitted for `AliasRelate` predicates, corresponding to the direction |
381 |
| - /// of the relation. |
382 |
| - fn alias_relate_direction(&self) -> ty::AliasRelationDirection; |
| 371 | + /// Register `AliasRelate` obligation(s) that both types must be related to each other. |
| 372 | + fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>); |
383 | 373 | }
|
384 | 374 |
|
385 | 375 | fn int_unification_error<'tcx>(
|
|
0 commit comments