Rollup merge of #120899 - compiler-errors:non-wf-alias, r=lcnr

Gracefully handle non-WF alias in `assemble_alias_bound_candidates_recur`

See explanation in test. I think it's fine to delay a bug here -- I don't believe we ever construct a non-wf alias on the good path? If so, then we can just remove the delay.

Fixes #120891

r? lcnr
This commit is contained in:
Matthias Krüger 2024-02-12 18:04:08 +01:00 committed by GitHub
commit 733f93d60c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 2 deletions

View file

@ -15,7 +15,7 @@ use rustc_middle::ty::fast_reject::{SimplifiedType, TreatParams};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{fast_reject, TypeFoldable};
use rustc_middle::ty::{ToPredicate, TypeVisitableExt};
use rustc_span::ErrorGuaranteed;
use rustc_span::{ErrorGuaranteed, DUMMY_SP};
use std::fmt::Debug;
pub(super) mod structural_traits;
@ -612,7 +612,11 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
ty::Alias(kind @ (ty::Projection | ty::Opaque), alias_ty) => (kind, alias_ty),
ty::Alias(ty::Inherent | ty::Weak, _) => {
unreachable!("Weak and Inherent aliases should have been normalized away already")
self.tcx().sess.dcx().span_delayed_bug(
DUMMY_SP,
format!("could not normalize {self_ty}, it is not WF"),
);
return;
}
};