Skip to content

Commit 64872a8

Browse files
committed
Avoid accessing HIR for RPITITs on check_type_bounds
1 parent 7a809ce commit 64872a8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,13 +1996,17 @@ pub(super) fn check_type_bounds<'tcx>(
19961996
let infcx = tcx.infer_ctxt().build();
19971997
let ocx = ObligationCtxt::new(&infcx);
19981998

1999-
let impl_ty_span = match tcx.hir().get_by_def_id(impl_ty_def_id) {
2000-
hir::Node::TraitItem(hir::TraitItem {
2001-
kind: hir::TraitItemKind::Type(_, Some(ty)),
2002-
..
2003-
}) => ty.span,
2004-
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span,
2005-
_ => bug!(),
1999+
let impl_ty_span = if tcx.opt_rpitit_info(impl_ty_def_id).is_some() {
2000+
tcx.def_span(impl_ty_def_id)
2001+
} else {
2002+
match tcx.hir().get_by_def_id(impl_ty_def_id) {
2003+
hir::Node::TraitItem(hir::TraitItem {
2004+
kind: hir::TraitItemKind::Type(_, Some(ty)),
2005+
..
2006+
}) => ty.span,
2007+
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span,
2008+
_ => bug!(),
2009+
}
20062010
};
20072011
let assumed_wf_types = ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty_def_id);
20082012

0 commit comments

Comments
 (0)