From 11adf037906fd918e0a77116db8c8b17e0fcee73 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 17 Nov 2022 09:58:22 +0000 Subject: [PATCH] Add some more assertions for type relations not used during coherence --- compiler/rustc_infer/src/infer/combine.rs | 5 +++-- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 3 ++- compiler/rustc_infer/src/infer/glb.rs | 5 +++-- compiler/rustc_infer/src/infer/lub.rs | 5 +++-- compiler/rustc_infer/src/infer/nll_relate/mod.rs | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index f8234df871b26..256a6dc47f40c 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -548,7 +548,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> { } fn mark_ambiguous(&mut self) { - self.infcx.tcx.sess.delay_span_bug(self.cause.span, "opaque types are handled in `tys`"); + 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"); } fn binders( @@ -818,7 +818,8 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> { } fn intercrate(&self) -> bool { - self.infcx.intercrate + assert!(!self.infcx.intercrate); + false } fn param_env(&self) -> ty::ParamEnv<'tcx> { diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 41e21efb212bb..da5d4ebf4171d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2938,7 +2938,8 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> { } fn intercrate(&self) -> bool { - self.0.intercrate + assert!(!self.0.intercrate); + false } fn param_env(&self) -> ty::ParamEnv<'tcx> { diff --git a/compiler/rustc_infer/src/infer/glb.rs b/compiler/rustc_infer/src/infer/glb.rs index 67f3e67e96322..7f27b35a54e4f 100644 --- a/compiler/rustc_infer/src/infer/glb.rs +++ b/compiler/rustc_infer/src/infer/glb.rs @@ -31,7 +31,8 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> { } fn intercrate(&self) -> bool { - self.fields.infcx.intercrate + assert!(!self.fields.infcx.intercrate); + false } fn tcx(&self) -> TyCtxt<'tcx> { @@ -47,7 +48,7 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> { } fn mark_ambiguous(&mut self) { - self.fields.mark_ambiguous(); + bug!("mark_ambiguous used outside of coherence"); } fn relate_with_variance>( diff --git a/compiler/rustc_infer/src/infer/lub.rs b/compiler/rustc_infer/src/infer/lub.rs index 1aaae714345c1..97ed4729bd0d9 100644 --- a/compiler/rustc_infer/src/infer/lub.rs +++ b/compiler/rustc_infer/src/infer/lub.rs @@ -31,7 +31,8 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> { } fn intercrate(&self) -> bool { - self.fields.infcx.intercrate + assert!(!self.fields.infcx.intercrate); + false } fn tcx(&self) -> TyCtxt<'tcx> { @@ -47,7 +48,7 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> { } fn mark_ambiguous(&mut self) { - self.fields.mark_ambiguous(); + bug!("mark_ambiguous used outside of coherence"); } fn relate_with_variance>( diff --git a/compiler/rustc_infer/src/infer/nll_relate/mod.rs b/compiler/rustc_infer/src/infer/nll_relate/mod.rs index 0687774078015..4f8460955c3de 100644 --- a/compiler/rustc_infer/src/infer/nll_relate/mod.rs +++ b/compiler/rustc_infer/src/infer/nll_relate/mod.rs @@ -914,7 +914,8 @@ where } fn intercrate(&self) -> bool { - self.infcx.intercrate + assert!(!self.infcx.intercrate); + false } fn param_env(&self) -> ty::ParamEnv<'tcx> {