Skip to content

Commit

Permalink
Remove param env from relation altogether
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Dec 19, 2023
1 parent 009cd9c commit a75d002
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 38 deletions.
4 changes: 0 additions & 4 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_infer/src/infer/relate/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>);

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_infer/src/infer/relate/generalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/ty/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a75d002

Please sign in to comment.