1
Fork 0

Avoid accessing HIR for RPITITs on check_type_bounds

This commit is contained in:
Santiago Pastorino 2023-03-03 12:29:56 -03:00
parent 47860ddf58
commit 97eaa5dbf4
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF

View file

@ -1995,13 +1995,20 @@ pub(super) fn check_type_bounds<'tcx>(
let infcx = tcx.infer_ctxt().build(); let infcx = tcx.infer_ctxt().build();
let ocx = ObligationCtxt::new(&infcx); let ocx = ObligationCtxt::new(&infcx);
let impl_ty_span = match tcx.hir().get_by_def_id(impl_ty_def_id) { // A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
hir::Node::TraitItem(hir::TraitItem { // span for an impl's associated type. Instead, for these, use the def_span for the synthesized
kind: hir::TraitItemKind::Type(_, Some(ty)), // associated type.
.. let impl_ty_span = if tcx.opt_rpitit_info(impl_ty.def_id).is_some() {
}) => ty.span, tcx.def_span(impl_ty_def_id)
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span, } else {
_ => bug!(), match tcx.hir().get_by_def_id(impl_ty_def_id) {
hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Type(_, Some(ty)),
..
}) => ty.span,
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span,
_ => bug!(),
}
}; };
let assumed_wf_types = ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty_def_id); let assumed_wf_types = ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty_def_id);