Remove param env from relation altogether

This commit is contained in:
Michael Goulet 2023-12-19 17:13:10 +00:00
parent 009cd9c815
commit a75d0021ed
11 changed files with 22 additions and 38 deletions

View file

@ -2653,10 +2653,6 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
self.0.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
unreachable!("purely structural relation should not need a param-env")
}
fn tag(&self) -> &'static str {
"SameTypeModuloInfer"
}

View file

@ -144,10 +144,6 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
self.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
unreachable!("purely structural relation should not need a param-env")
}
fn a_is_expected(&self) -> bool {
true
} // irrelevant

View file

@ -563,6 +563,8 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
}
pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx>;
/// Register obligations that must hold in order for this relation to hold
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>);

View file

@ -33,10 +33,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
self.fields.tcx()
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn a_is_expected(&self) -> bool {
self.a_is_expected
}
@ -174,6 +170,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
}
impl<'tcx> ObligationEmittingRelation<'tcx> for Equate<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}

View file

@ -182,10 +182,6 @@ where
self.infcx.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.delegate.param_env()
}
fn tag(&self) -> &'static str {
"Generalizer"
}

View file

@ -32,10 +32,6 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
self.fields.tcx()
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn a_is_expected(&self) -> bool {
self.a_is_expected
}
@ -138,6 +134,10 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx,
}
impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}

View file

@ -32,10 +32,6 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
self.fields.tcx()
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn a_is_expected(&self) -> bool {
self.a_is_expected
}
@ -138,6 +134,10 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx,
}
impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}

View file

@ -431,10 +431,6 @@ where
self.infcx.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.delegate.param_env()
}
fn tag(&self) -> &'static str {
"nll::subtype"
}
@ -670,6 +666,10 @@ impl<'tcx, D> ObligationEmittingRelation<'tcx> for TypeRelating<'_, 'tcx, D>
where
D: TypeRelatingDelegate<'tcx>,
{
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.delegate.param_env()
}
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.delegate.register_obligations(
obligations

View file

@ -39,10 +39,6 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
self.fields.infcx.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn a_is_expected(&self) -> bool {
self.a_is_expected
}
@ -203,6 +199,10 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
}
impl<'tcx> ObligationEmittingRelation<'tcx> for Sub<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}

View file

@ -37,10 +37,6 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
self.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
panic!("relation should not need a param-env")
}
fn a_is_expected(&self) -> bool {
true
} // irrelevant

View file

@ -23,8 +23,6 @@ pub enum Cause {
pub trait TypeRelation<'tcx>: Sized {
fn tcx(&self) -> TyCtxt<'tcx>;
fn param_env(&self) -> ty::ParamEnv<'tcx>;
/// Returns a static string we can use for printouts.
fn tag(&self) -> &'static str;