1
Fork 0

Avoid ICEing when associated type bound trait is missing

This commit is contained in:
Santiago Pastorino 2020-11-19 19:03:59 -03:00
parent 5b6f206d23
commit 3c8cf6d802
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
3 changed files with 41 additions and 7 deletions

View file

@ -652,13 +652,21 @@ impl ItemCtxt<'tcx> {
match b {
hir::GenericBound::Trait(poly_trait_ref, _) => {
let trait_ref = &poly_trait_ref.trait_ref;
let trait_did = trait_ref.trait_def_id().unwrap();
super_traits_of(self.tcx, trait_did).any(|trait_did| {
self.tcx
.associated_items(trait_did)
.find_by_name_and_kind(self.tcx, assoc_name, ty::AssocKind::Type, trait_did)
.is_some()
})
if let Some(trait_did) = trait_ref.trait_def_id() {
super_traits_of(self.tcx, trait_did).any(|trait_did| {
self.tcx
.associated_items(trait_did)
.find_by_name_and_kind(
self.tcx,
assoc_name,
ty::AssocKind::Type,
trait_did,
)
.is_some()
})
} else {
false
}
}
_ => false,
}