1
Fork 0

Directly call relate_types function instead of having a method wrapper

This commit is contained in:
Oli Scherer 2021-10-08 17:53:41 +00:00
parent 597090ee14
commit 49b06a2b60
2 changed files with 26 additions and 37 deletions

View file

@ -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,

View file

@ -9,6 +9,7 @@ use crate::constraints::OutlivesConstraint;
use crate::diagnostics::UniverseInfo; use crate::diagnostics::UniverseInfo;
use crate::type_check::{Locations, TypeChecker}; use crate::type_check::{Locations, TypeChecker};
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`: /// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
/// ///
/// - "Covariant" `a <: b` /// - "Covariant" `a <: b`
@ -17,9 +18,9 @@ use crate::type_check::{Locations, TypeChecker};
/// ///
/// N.B., the type `a` is permitted to have unresolved inference /// N.B., the type `a` is permitted to have unresolved inference
/// variables, but not the type `b`. /// variables, but not the type `b`.
#[instrument(skip(type_checker), level = "debug")] #[instrument(skip(self), level = "debug")]
pub(super) fn relate_types<'tcx>( pub(super) fn relate_types(
type_checker: &mut TypeChecker<'_, 'tcx>, &mut self,
a: Ty<'tcx>, a: Ty<'tcx>,
v: ty::Variance, v: ty::Variance,
b: Ty<'tcx>, b: Ty<'tcx>,
@ -27,13 +28,14 @@ pub(super) fn relate_types<'tcx>(
category: ConstraintCategory, category: ConstraintCategory,
) -> Fallible<()> { ) -> Fallible<()> {
TypeRelating::new( TypeRelating::new(
type_checker.infcx, self.infcx,
NllTypeRelatingDelegate::new(type_checker, locations, category, UniverseInfo::relate(a, b)), NllTypeRelatingDelegate::new(self, locations, category, UniverseInfo::relate(a, b)),
v, v,
) )
.relate(a, b)?; .relate(a, b)?;
Ok(()) Ok(())
} }
}
struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
type_checker: &'me mut TypeChecker<'bccx, 'tcx>, type_checker: &'me mut TypeChecker<'bccx, 'tcx>,