// Find non representable fields with their spans
fold_repr(def.all_fields().map(|field| {
let ty = field.ty(tcx, substs);
- let span = tcx.hir().span_if_local(field.did).unwrap_or(sp);
+ let span = match field
+ .did
+ .as_local()
+ .map(|id| tcx.hir().as_local_hir_id(id))
+ .and_then(|id| tcx.hir().find(id))
+ {
+ Some(hir::Node::Field(field)) => field.ty.span,
+ _ => sp,
+ };
match is_type_structurally_recursive(
tcx,
span,