Do not ICE with TraitPredicates containing [type error]

Fix #77919.
This commit is contained in:
Esteban Küber 2020-10-13 21:42:59 -07:00
parent 07a63e6d1f
commit b334eef162
3 changed files with 72 additions and 6 deletions

View file

@ -2031,12 +2031,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&predicate.subst(tcx, substs),
&mut obligations,
);
obligations.push(Obligation {
cause: cause.clone(),
recursion_depth,
param_env,
predicate,
});
if predicate.references_error() {
self.tcx().sess.delay_span_bug(
cause.span,
&format!("impl_or_trait_obligation with errors: {:?}", predicate),
);
} else {
obligations.push(Obligation {
cause: cause.clone(),
recursion_depth,
param_env,
predicate,
});
}
}
// We are performing deduplication here to avoid exponential blowups