1
Fork 0

Fix rustc_hidden_type_of_opaques for RPITITs with no default body

This commit is contained in:
Michael Goulet 2025-02-04 17:53:24 +00:00
parent 7b31983d55
commit 009feeb83e
3 changed files with 32 additions and 0 deletions

View file

@ -11,6 +11,15 @@ pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
}
for id in tcx.hir_crate_items(()).opaques() {
if let hir::OpaqueTyOrigin::FnReturn { parent: fn_def_id, .. }
| hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, .. } =
tcx.hir().expect_opaque_ty(id).origin
&& let hir::Node::TraitItem(trait_item) = tcx.hir_node_by_def_id(fn_def_id)
&& let (_, hir::TraitFn::Required(..)) = trait_item.expect_fn()
{
continue;
}
let ty = tcx.type_of(id).instantiate_identity();
let span = tcx.def_span(id);
tcx.dcx().emit_err(crate::errors::TypeOf { span, ty });