Skip to content

Commit

Permalink
Add some more assertions for type relations not used during coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Nov 21, 2022
1 parent 7301cd7 commit 11adf03
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_infer/src/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(
Expand Down Expand Up @@ -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> {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_infer/src/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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<T: Relate<'tcx>>(
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_infer/src/infer/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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<T: Relate<'tcx>>(
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_infer/src/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ where
}

fn intercrate(&self) -> bool {
self.infcx.intercrate
assert!(!self.infcx.intercrate);
false
}

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

0 comments on commit 11adf03

Please sign in to comment.