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);
|
||||
}
|
||||
|
||||
/// 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`
|
||||
fn sub_types(
|
||||
&mut self,
|
||||
|
|
|
@ -9,30 +9,32 @@ use crate::constraints::OutlivesConstraint;
|
|||
use crate::diagnostics::UniverseInfo;
|
||||
use crate::type_check::{Locations, TypeChecker};
|
||||
|
||||
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
|
||||
///
|
||||
/// - "Covariant" `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`.
|
||||
#[instrument(skip(type_checker), level = "debug")]
|
||||
pub(super) fn relate_types<'tcx>(
|
||||
type_checker: &mut TypeChecker<'_, 'tcx>,
|
||||
a: Ty<'tcx>,
|
||||
v: ty::Variance,
|
||||
b: Ty<'tcx>,
|
||||
locations: Locations,
|
||||
category: ConstraintCategory,
|
||||
) -> Fallible<()> {
|
||||
TypeRelating::new(
|
||||
type_checker.infcx,
|
||||
NllTypeRelatingDelegate::new(type_checker, locations, category, UniverseInfo::relate(a, b)),
|
||||
v,
|
||||
)
|
||||
.relate(a, b)?;
|
||||
Ok(())
|
||||
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`
|
||||
/// - "Contravariant" `a :> b`
|
||||
///
|
||||
/// N.B., the type `a` is permitted to have unresolved inference
|
||||
/// variables, but not the type `b`.
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
pub(super) fn relate_types(
|
||||
&mut self,
|
||||
a: Ty<'tcx>,
|
||||
v: ty::Variance,
|
||||
b: Ty<'tcx>,
|
||||
locations: Locations,
|
||||
category: ConstraintCategory,
|
||||
) -> Fallible<()> {
|
||||
TypeRelating::new(
|
||||
self.infcx,
|
||||
NllTypeRelatingDelegate::new(self, locations, category, UniverseInfo::relate(a, b)),
|
||||
v,
|
||||
)
|
||||
.relate(a, b)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue