Skip to content

Commit b87a9a8

Browse files
authored
Rollup merge of #89329 - tmiasko:print-type-sizes-no-fields, r=jackh726
print-type-sizes: skip field printing for primitives Fixes #86528.
2 parents b4615b5 + 25b6f9b commit b87a9a8

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

compiler/rustc_middle/src/ty/layout.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1826,8 +1826,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
18261826

18271827
match layout.variants {
18281828
Variants::Single { index } => {
1829-
debug!("print-type-size `{:#?}` variant {}", layout, adt_def.variants[index].ident);
1830-
if !adt_def.variants.is_empty() {
1829+
if !adt_def.variants.is_empty() && layout.fields != FieldsShape::Primitive {
1830+
debug!(
1831+
"print-type-size `{:#?}` variant {}",
1832+
layout, adt_def.variants[index].ident
1833+
);
18311834
let variant_def = &adt_def.variants[index];
18321835
let fields: Vec<_> = variant_def.fields.iter().map(|f| f.ident.name).collect();
18331836
record(

src/test/ui/print_type_sizes/uninhabited.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
fn start(_: isize, _: *const *const u8) -> isize {
1212
let _x: Option<!> = None;
1313
let _y: Result<u32, !> = Ok(42);
14-
0
14+
let _z: Result<!, !> = loop {};
1515
}

src/test/ui/print_type_sizes/uninhabited.stdout

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ print-type-size variant `Ok`: 4 bytes
33
print-type-size field `.0`: 4 bytes
44
print-type-size type: `std::option::Option<!>`: 0 bytes, alignment: 1 bytes
55
print-type-size variant `None`: 0 bytes
6+
print-type-size type: `std::result::Result<!, !>`: 0 bytes, alignment: 1 bytes

0 commit comments

Comments
 (0)