Skip to content

Commit

Permalink
Associated types in traits don't necessarily have a type that we can …
Browse files Browse the repository at this point in the history
…visit

This prevents ICEs from happening in the future when this code path is actually used
  • Loading branch information
oli-obk committed Feb 7, 2024
1 parent d4f6f9e commit 0f323b2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions compiler/rustc_ty_utils/src/sig_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
DefKind::TyAlias {..} | DefKind::AssocTy |
// Walk over the type of the item
DefKind::Static(_) | DefKind::Const | DefKind::AssocConst | DefKind::AnonConst => {
let span = match tcx.hir_node_by_def_id(item).ty() {
Some(ty) => ty.span,
_ => tcx.def_span(item),
};
visitor.visit(span, tcx.type_of(item).instantiate_identity());
if let Some(ty) = tcx.hir_node_by_def_id(item).ty() {
// Associated types in traits don't necessarily have a type that we can visit
visitor.visit(ty.span, tcx.type_of(item).instantiate_identity())?;
}
for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) {
visitor.visit(span, pred)?;
}
Expand Down

0 comments on commit 0f323b2

Please sign in to comment.