Skip to content

Commit 55a2446

Browse files
committed
Don't panic when layout can't be computed and fix generation of array type debuginfo
1 parent fee1204 commit 55a2446

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/debuginfo/types.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
use gimli::write::{AttributeValue, UnitEntryId};
44
use rustc_codegen_ssa::debuginfo::type_names;
55
use rustc_data_structures::fx::FxHashMap;
6+
use rustc_middle::ty::layout::LayoutOf;
67
use rustc_middle::ty::{self, Ty, TyCtxt};
78

8-
use crate::{has_ptr_meta, DebugContext};
9+
use crate::{has_ptr_meta, DebugContext, RevealAllLayoutCx};
910

1011
#[derive(Default)]
1112
pub(crate) struct TypeDebugContext<'tcx> {
@@ -41,6 +42,7 @@ impl DebugContext {
4142
ty::Array(elem_ty, len) => self.array_type(
4243
tcx,
4344
type_dbg,
45+
ty,
4446
*elem_ty,
4547
len.eval_target_usize(tcx, ty::ParamEnv::reveal_all()),
4648
),
@@ -83,9 +85,7 @@ impl DebugContext {
8385
type_entry.set(gimli::DW_AT_encoding, AttributeValue::Encoding(encoding));
8486
type_entry.set(
8587
gimli::DW_AT_byte_size,
86-
AttributeValue::Udata(
87-
tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).expect("FIXME").size.bytes(),
88-
),
88+
AttributeValue::Udata(RevealAllLayoutCx(tcx).layout_of(ty).size.bytes()),
8989
);
9090

9191
type_id
@@ -95,12 +95,13 @@ impl DebugContext {
9595
&mut self,
9696
tcx: TyCtxt<'tcx>,
9797
type_dbg: &mut TypeDebugContext<'tcx>,
98+
array_ty: Ty<'tcx>,
9899
elem_ty: Ty<'tcx>,
99100
len: u64,
100101
) -> UnitEntryId {
101102
let elem_dw_ty = self.debug_type(tcx, type_dbg, elem_ty);
102103

103-
return_if_type_created_in_meantime!(type_dbg, elem_ty);
104+
return_if_type_created_in_meantime!(type_dbg, array_ty);
104105

105106
let array_type_id = self.dwarf.unit.add(self.dwarf.unit.root(), gimli::DW_TAG_array_type);
106107
let array_type_entry = self.dwarf.unit.get_mut(array_type_id);
@@ -152,11 +153,7 @@ impl DebugContext {
152153
self.debug_type(
153154
tcx,
154155
type_dbg,
155-
Ty::new_array(
156-
tcx,
157-
tcx.types.u8,
158-
tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap().size.bytes(),
159-
),
156+
Ty::new_array(tcx, tcx.types.u8, RevealAllLayoutCx(tcx).layout_of(ty).size.bytes()),
160157
)
161158
}
162159
}

0 commit comments

Comments
 (0)