rustdoc: Use accessors to interrogate type layouts

This commit is contained in:
Jubilee Young 2024-10-27 21:36:52 -07:00
parent 88a9edc091
commit 641ce068ae

View File

@ -60,8 +60,8 @@ pub(crate) fn document_type_layout<'a, 'cx: 'a>(
span_bug!(tcx.def_span(ty_def_id), "not an adt") span_bug!(tcx.def_span(ty_def_id), "not an adt")
}; };
let name = adt.variant(variant_idx).name; let name = adt.variant(variant_idx).name;
let is_unsized = variant_layout.abi.is_unsized(); let is_unsized = variant_layout.is_unsized();
let is_uninhabited = variant_layout.abi.is_uninhabited(); let is_uninhabited = variant_layout.is_uninhabited();
let size = variant_layout.size.bytes() - tag_size; let size = variant_layout.size.bytes() - tag_size;
let type_layout_size = TypeLayoutSize { is_unsized, is_uninhabited, size }; let type_layout_size = TypeLayoutSize { is_unsized, is_uninhabited, size };
(name, type_layout_size) (name, type_layout_size)
@ -72,8 +72,8 @@ pub(crate) fn document_type_layout<'a, 'cx: 'a>(
}; };
let type_layout_size = tcx.layout_of(param_env.and(ty)).map(|layout| { let type_layout_size = tcx.layout_of(param_env.and(ty)).map(|layout| {
let is_unsized = layout.abi.is_unsized(); let is_unsized = layout.is_unsized();
let is_uninhabited = layout.abi.is_uninhabited(); let is_uninhabited = layout.is_uninhabited();
let size = layout.size.bytes(); let size = layout.size.bytes();
TypeLayoutSize { is_unsized, is_uninhabited, size } TypeLayoutSize { is_unsized, is_uninhabited, size }
}); });