Skip to content

Commit 11adf03

Browse files
committed
Add some more assertions for type relations not used during coherence
1 parent 7301cd7 commit 11adf03

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

compiler/rustc_infer/src/infer/combine.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
548548
}
549549

550550
fn mark_ambiguous(&mut self) {
551-
self.infcx.tcx.sess.delay_span_bug(self.cause.span, "opaque types are handled in `tys`");
551+
self.infcx.tcx.sess.delay_span_bug(self.cause.span, "we only generalize opaque types in situations where we already error for them elsewhere in coherence");
552552
}
553553

554554
fn binders<T>(
@@ -818,7 +818,8 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
818818
}
819819

820820
fn intercrate(&self) -> bool {
821-
self.infcx.intercrate
821+
assert!(!self.infcx.intercrate);
822+
false
822823
}
823824

824825
fn param_env(&self) -> ty::ParamEnv<'tcx> {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2938,7 +2938,8 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
29382938
}
29392939

29402940
fn intercrate(&self) -> bool {
2941-
self.0.intercrate
2941+
assert!(!self.0.intercrate);
2942+
false
29422943
}
29432944

29442945
fn param_env(&self) -> ty::ParamEnv<'tcx> {

compiler/rustc_infer/src/infer/glb.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
3131
}
3232

3333
fn intercrate(&self) -> bool {
34-
self.fields.infcx.intercrate
34+
assert!(!self.fields.infcx.intercrate);
35+
false
3536
}
3637

3738
fn tcx(&self) -> TyCtxt<'tcx> {
@@ -47,7 +48,7 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
4748
}
4849

4950
fn mark_ambiguous(&mut self) {
50-
self.fields.mark_ambiguous();
51+
bug!("mark_ambiguous used outside of coherence");
5152
}
5253

5354
fn relate_with_variance<T: Relate<'tcx>>(

compiler/rustc_infer/src/infer/lub.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
3131
}
3232

3333
fn intercrate(&self) -> bool {
34-
self.fields.infcx.intercrate
34+
assert!(!self.fields.infcx.intercrate);
35+
false
3536
}
3637

3738
fn tcx(&self) -> TyCtxt<'tcx> {
@@ -47,7 +48,7 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
4748
}
4849

4950
fn mark_ambiguous(&mut self) {
50-
self.fields.mark_ambiguous();
51+
bug!("mark_ambiguous used outside of coherence");
5152
}
5253

5354
fn relate_with_variance<T: Relate<'tcx>>(

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,8 @@ where
914914
}
915915

916916
fn intercrate(&self) -> bool {
917-
self.infcx.intercrate
917+
assert!(!self.infcx.intercrate);
918+
false
918919
}
919920

920921
fn param_env(&self) -> ty::ParamEnv<'tcx> {

0 commit comments

Comments
 (0)