Skip to content

Commit 11ff067

Browse files
committed
Expand on #145967 by including spans in layout errors for all ADTs
1 parent f5c6c95 commit 11ff067

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ pub(crate) fn spanned_type_di_node<'ll, 'tcx>(
469469
ty::CoroutineClosure(..) => build_closure_env_di_node(cx, unique_type_id),
470470
ty::Coroutine(..) => enums::build_coroutine_di_node(cx, unique_type_id),
471471
ty::Adt(def, ..) => match def.adt_kind() {
472-
AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id),
473-
AdtKind::Union => build_union_type_di_node(cx, unique_type_id),
472+
AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id, span),
473+
AdtKind::Union => build_union_type_di_node(cx, unique_type_id, span),
474474
AdtKind::Enum => enums::build_enum_type_di_node(cx, unique_type_id, span),
475475
},
476476
ty::Tuple(_) => build_tuple_type_di_node(cx, unique_type_id),
@@ -1066,14 +1066,15 @@ fn visibility_di_flags<'ll, 'tcx>(
10661066
fn build_struct_type_di_node<'ll, 'tcx>(
10671067
cx: &CodegenCx<'ll, 'tcx>,
10681068
unique_type_id: UniqueTypeId<'tcx>,
1069+
span: Span,
10691070
) -> DINodeCreationResult<'ll> {
10701071
let struct_type = unique_type_id.expect_ty();
10711072
let ty::Adt(adt_def, _) = struct_type.kind() else {
10721073
bug!("build_struct_type_di_node() called with non-struct-type: {:?}", struct_type);
10731074
};
10741075
assert!(adt_def.is_struct());
10751076
let containing_scope = get_namespace_for_item(cx, adt_def.did());
1076-
let struct_type_and_layout = cx.layout_of(struct_type);
1077+
let struct_type_and_layout = cx.spanned_layout_of(struct_type, span);
10771078
let variant_def = adt_def.non_enum_variant();
10781079
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
10791080
Some(file_metadata_from_def_id(cx, Some(adt_def.did())))
@@ -1266,14 +1267,15 @@ fn build_closure_env_di_node<'ll, 'tcx>(
12661267
fn build_union_type_di_node<'ll, 'tcx>(
12671268
cx: &CodegenCx<'ll, 'tcx>,
12681269
unique_type_id: UniqueTypeId<'tcx>,
1270+
span: Span,
12691271
) -> DINodeCreationResult<'ll> {
12701272
let union_type = unique_type_id.expect_ty();
12711273
let (union_def_id, variant_def) = match union_type.kind() {
12721274
ty::Adt(def, _) => (def.did(), def.non_enum_variant()),
12731275
_ => bug!("build_union_type_di_node on a non-ADT"),
12741276
};
12751277
let containing_scope = get_namespace_for_item(cx, union_def_id);
1276-
let union_ty_and_layout = cx.layout_of(union_type);
1278+
let union_ty_and_layout = cx.spanned_layout_of(union_type, span);
12771279
let type_name = compute_debuginfo_type_name(cx.tcx, union_type, false);
12781280
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
12791281
Some(file_metadata_from_def_id(cx, Some(union_def_id)))

0 commit comments

Comments
 (0)