Rollup merge of #104427 - compiler-errors:rematch-impl-may-fail-actually, r=lcnr

Explain why `rematch_impl` fails to be infallible

Fixes #104395

r? `@lcnr`
This commit is contained in:
Matthias Krüger 2022-11-29 22:43:16 +01:00 committed by GitHub
commit d88699f9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2140,6 +2140,13 @@ fn rematch_impl(
match self.match_impl(impl_def_id, impl_trait_ref, obligation) {
Ok(substs) => substs,
Err(()) => {
// FIXME: A rematch may fail when a candidate cache hit occurs
// on thefreshened form of the trait predicate, but the match
// fails for some reason that is not captured in the freshened
// cache key. For example, equating an impl trait ref against
// the placeholder trait ref may fail due the Generalizer relation
// raising a CyclicalTy error due to a sub_root_var relation
// for a variable being generalized...
self.infcx.tcx.sess.delay_span_bug(
obligation.cause.span,
&format!(