Directly call relate_types function instead of having a method wrapper
This commit is contained in:
parent
597090ee14
commit
49b06a2b60
2 changed files with 26 additions and 37 deletions
|
@ -1153,19 +1153,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
.convert_all(data);
|
.convert_all(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenient wrapper around `relate_tys::relate_types` -- see
|
|
||||||
/// that fn for docs.
|
|
||||||
fn relate_types(
|
|
||||||
&mut self,
|
|
||||||
a: Ty<'tcx>,
|
|
||||||
v: ty::Variance,
|
|
||||||
b: Ty<'tcx>,
|
|
||||||
locations: Locations,
|
|
||||||
category: ConstraintCategory,
|
|
||||||
) -> Fallible<()> {
|
|
||||||
relate_tys::relate_types(self, a, v, b, locations, category)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Try to relate `sub <: sup`
|
/// Try to relate `sub <: sup`
|
||||||
fn sub_types(
|
fn sub_types(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
@ -9,30 +9,32 @@ use crate::constraints::OutlivesConstraint;
|
||||||
use crate::diagnostics::UniverseInfo;
|
use crate::diagnostics::UniverseInfo;
|
||||||
use crate::type_check::{Locations, TypeChecker};
|
use crate::type_check::{Locations, TypeChecker};
|
||||||
|
|
||||||
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
|
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
///
|
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
|
||||||
/// - "Covariant" `a <: b`
|
///
|
||||||
/// - "Invariant" `a == b`
|
/// - "Covariant" `a <: b`
|
||||||
/// - "Contravariant" `a :> b`
|
/// - "Invariant" `a == b`
|
||||||
///
|
/// - "Contravariant" `a :> b`
|
||||||
/// N.B., the type `a` is permitted to have unresolved inference
|
///
|
||||||
/// variables, but not the type `b`.
|
/// N.B., the type `a` is permitted to have unresolved inference
|
||||||
#[instrument(skip(type_checker), level = "debug")]
|
/// variables, but not the type `b`.
|
||||||
pub(super) fn relate_types<'tcx>(
|
#[instrument(skip(self), level = "debug")]
|
||||||
type_checker: &mut TypeChecker<'_, 'tcx>,
|
pub(super) fn relate_types(
|
||||||
a: Ty<'tcx>,
|
&mut self,
|
||||||
v: ty::Variance,
|
a: Ty<'tcx>,
|
||||||
b: Ty<'tcx>,
|
v: ty::Variance,
|
||||||
locations: Locations,
|
b: Ty<'tcx>,
|
||||||
category: ConstraintCategory,
|
locations: Locations,
|
||||||
) -> Fallible<()> {
|
category: ConstraintCategory,
|
||||||
TypeRelating::new(
|
) -> Fallible<()> {
|
||||||
type_checker.infcx,
|
TypeRelating::new(
|
||||||
NllTypeRelatingDelegate::new(type_checker, locations, category, UniverseInfo::relate(a, b)),
|
self.infcx,
|
||||||
v,
|
NllTypeRelatingDelegate::new(self, locations, category, UniverseInfo::relate(a, b)),
|
||||||
)
|
v,
|
||||||
.relate(a, b)?;
|
)
|
||||||
Ok(())
|
.relate(a, b)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
|
struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue