Rollup merge of #103621 - fee1-dead-contrib:iat-fix-use, r=cjgillot

Correctly resolve Inherent Associated Types

I don't know if this is the best way to do this, but at least it is one way.
This commit is contained in:
Dylan DPC 2022-11-05 11:31:28 +05:30 committed by GitHub
commit 3450aa38d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 67 additions and 73 deletions

View file

@ -1910,6 +1910,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
}
}
// see if we can satisfy using an inherent associated type
for impl_ in tcx.inherent_impls(adt_def.did()) {
let assoc_ty = tcx.associated_items(impl_).find_by_name_and_kind(
tcx,
assoc_ident,
ty::AssocKind::Type,
*impl_,
);
if let Some(assoc_ty) = assoc_ty {
let ty = tcx.type_of(assoc_ty.def_id);
return Ok((ty, DefKind::AssocTy, assoc_ty.def_id));
}
}
}
// Find the type of the associated item, and the trait where the associated