|
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 crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace};
|
30 | 31 | use crate::traits::{Obligation, PredicateObligations};
|
31 | 32 | use rustc_middle::infer::canonical::OriginalQueryValues;
|
@@ -303,12 +304,12 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
303 | 304 | self.infcx.tcx
|
304 | 305 | }
|
305 | 306 |
|
306 |
| - pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'tcx> { |
307 |
| - Equate::new(self, a_is_expected) |
| 307 | + pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> TypeRelating<'a, 'infcx, 'tcx> { |
| 308 | + TypeRelating::new(self, a_is_expected, ty::Invariant) |
308 | 309 | }
|
309 | 310 |
|
310 |
| - pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'tcx> { |
311 |
| - Sub::new(self, a_is_expected) |
| 311 | + pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> TypeRelating<'a, 'infcx, 'tcx> { |
| 312 | + TypeRelating::new(self, a_is_expected, ty::Covariant) |
312 | 313 | }
|
313 | 314 |
|
314 | 315 | pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'tcx> {
|
@@ -343,19 +344,8 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
|
343 | 344 | /// be used if control over the obligation causes is required.
|
344 | 345 | fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>);
|
345 | 346 |
|
346 |
| - /// Register an obligation that both types must be related to each other according to |
347 |
| - /// the [`ty::AliasRelationDirection`] given by [`ObligationEmittingRelation::alias_relate_direction`] |
348 |
| - fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) { |
349 |
| - self.register_predicates([ty::Binder::dummy(ty::PredicateKind::AliasRelate( |
350 |
| - a.into(), |
351 |
| - b.into(), |
352 |
| - self.alias_relate_direction(), |
353 |
| - ))]); |
354 |
| - } |
355 |
| - |
356 |
| - /// Relation direction emitted for `AliasRelate` predicates, corresponding to the direction |
357 |
| - /// of the relation. |
358 |
| - fn alias_relate_direction(&self) -> ty::AliasRelationDirection; |
| 347 | + /// Register `AliasRelate` obligation(s) that both types must be related to each other. |
| 348 | + fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>); |
359 | 349 | }
|
360 | 350 |
|
361 | 351 | fn int_unification_error<'tcx>(
|
|
0 commit comments