Skip to content

Commit a75d002

Browse files
Remove param env from relation altogether
1 parent 009cd9c commit a75d002

File tree

11 files changed

+22
-38
lines changed

11 files changed

+22
-38
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2653,10 +2653,6 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
26532653
self.0.tcx
26542654
}
26552655

2656-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
2657-
unreachable!("purely structural relation should not need a param-env")
2658-
}
2659-
26602656
fn tag(&self) -> &'static str {
26612657
"SameTypeModuloInfer"
26622658
}

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
144144
self.tcx
145145
}
146146

147-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
148-
unreachable!("purely structural relation should not need a param-env")
149-
}
150-
151147
fn a_is_expected(&self) -> bool {
152148
true
153149
} // irrelevant

compiler/rustc_infer/src/infer/relate/combine.rs

+2
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
563563
}
564564

565565
pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
566+
fn param_env(&self) -> ty::ParamEnv<'tcx>;
567+
566568
/// Register obligations that must hold in order for this relation to hold
567569
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>);
568570

compiler/rustc_infer/src/infer/relate/equate.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
3333
self.fields.tcx()
3434
}
3535

36-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
37-
self.fields.param_env
38-
}
39-
4036
fn a_is_expected(&self) -> bool {
4137
self.a_is_expected
4238
}
@@ -174,6 +170,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
174170
}
175171

176172
impl<'tcx> ObligationEmittingRelation<'tcx> for Equate<'_, '_, 'tcx> {
173+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
174+
self.fields.param_env
175+
}
176+
177177
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
178178
self.fields.register_predicates(obligations);
179179
}

compiler/rustc_infer/src/infer/relate/generalize.rs

-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ where
182182
self.infcx.tcx
183183
}
184184

185-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
186-
self.delegate.param_env()
187-
}
188-
189185
fn tag(&self) -> &'static str {
190186
"Generalizer"
191187
}

compiler/rustc_infer/src/infer/relate/glb.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
3232
self.fields.tcx()
3333
}
3434

35-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
36-
self.fields.param_env
37-
}
38-
3935
fn a_is_expected(&self) -> bool {
4036
self.a_is_expected
4137
}
@@ -138,6 +134,10 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx,
138134
}
139135

140136
impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
137+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
138+
self.fields.param_env
139+
}
140+
141141
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
142142
self.fields.register_predicates(obligations);
143143
}

compiler/rustc_infer/src/infer/relate/lub.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
3232
self.fields.tcx()
3333
}
3434

35-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
36-
self.fields.param_env
37-
}
38-
3935
fn a_is_expected(&self) -> bool {
4036
self.a_is_expected
4137
}
@@ -138,6 +134,10 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx,
138134
}
139135

140136
impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
137+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
138+
self.fields.param_env
139+
}
140+
141141
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
142142
self.fields.register_predicates(obligations);
143143
}

compiler/rustc_infer/src/infer/relate/nll.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,6 @@ where
431431
self.infcx.tcx
432432
}
433433

434-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
435-
self.delegate.param_env()
436-
}
437-
438434
fn tag(&self) -> &'static str {
439435
"nll::subtype"
440436
}
@@ -670,6 +666,10 @@ impl<'tcx, D> ObligationEmittingRelation<'tcx> for TypeRelating<'_, 'tcx, D>
670666
where
671667
D: TypeRelatingDelegate<'tcx>,
672668
{
669+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
670+
self.delegate.param_env()
671+
}
672+
673673
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
674674
self.delegate.register_obligations(
675675
obligations

compiler/rustc_infer/src/infer/relate/sub.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
3939
self.fields.infcx.tcx
4040
}
4141

42-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
43-
self.fields.param_env
44-
}
45-
4642
fn a_is_expected(&self) -> bool {
4743
self.a_is_expected
4844
}
@@ -203,6 +199,10 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
203199
}
204200

205201
impl<'tcx> ObligationEmittingRelation<'tcx> for Sub<'_, '_, 'tcx> {
202+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
203+
self.fields.param_env
204+
}
205+
206206
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
207207
self.fields.register_predicates(obligations);
208208
}

compiler/rustc_middle/src/ty/_match.rs

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
3737
self.tcx
3838
}
3939

40-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
41-
panic!("relation should not need a param-env")
42-
}
43-
4440
fn a_is_expected(&self) -> bool {
4541
true
4642
} // irrelevant

compiler/rustc_middle/src/ty/relate.rs

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ pub enum Cause {
2323
pub trait TypeRelation<'tcx>: Sized {
2424
fn tcx(&self) -> TyCtxt<'tcx>;
2525

26-
fn param_env(&self) -> ty::ParamEnv<'tcx>;
27-
2826
/// Returns a static string we can use for printouts.
2927
fn tag(&self) -> &'static str;
3028

0 commit comments

Comments
 (0)