summaryrefslogtreecommitdiffstats
path: root/tests/ui/print_type_sizes
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/print_type_sizes/anonymous.rs (renamed from src/test/ui/print_type_sizes/anonymous.rs)0
-rw-r--r--tests/ui/print_type_sizes/async.rs11
-rw-r--r--tests/ui/print_type_sizes/async.stdout34
-rw-r--r--tests/ui/print_type_sizes/generator.rs18
-rw-r--r--tests/ui/print_type_sizes/generator.stdout10
-rw-r--r--tests/ui/print_type_sizes/generator_discr_placement.rs23
-rw-r--r--tests/ui/print_type_sizes/generator_discr_placement.stdout11
-rw-r--r--tests/ui/print_type_sizes/generics.rs51
-rw-r--r--tests/ui/print_type_sizes/generics.stdout (renamed from src/test/ui/print_type_sizes/generics.stdout)0
-rw-r--r--tests/ui/print_type_sizes/multiple_types.rs13
-rw-r--r--tests/ui/print_type_sizes/multiple_types.stdout (renamed from src/test/ui/print_type_sizes/multiple_types.stdout)0
-rw-r--r--tests/ui/print_type_sizes/niche-filling.rs (renamed from src/test/ui/print_type_sizes/niche-filling.rs)10
-rw-r--r--tests/ui/print_type_sizes/niche-filling.stdout (renamed from src/test/ui/print_type_sizes/niche-filling.stdout)0
-rw-r--r--tests/ui/print_type_sizes/no_duplicates.rs (renamed from src/test/ui/print_type_sizes/no_duplicates.rs)8
-rw-r--r--tests/ui/print_type_sizes/no_duplicates.stdout (renamed from src/test/ui/print_type_sizes/no_duplicates.stdout)0
-rw-r--r--tests/ui/print_type_sizes/packed.rs59
-rw-r--r--tests/ui/print_type_sizes/packed.stdout (renamed from src/test/ui/print_type_sizes/packed.stdout)0
-rw-r--r--tests/ui/print_type_sizes/padding.rs (renamed from src/test/ui/print_type_sizes/padding.rs)8
-rw-r--r--tests/ui/print_type_sizes/padding.stdout (renamed from src/test/ui/print_type_sizes/padding.stdout)0
-rw-r--r--tests/ui/print_type_sizes/repr-align.rs (renamed from src/test/ui/print_type_sizes/repr-align.rs)12
-rw-r--r--tests/ui/print_type_sizes/repr-align.stdout (renamed from src/test/ui/print_type_sizes/repr-align.stdout)0
-rw-r--r--tests/ui/print_type_sizes/repr_int_c.rs19
-rw-r--r--tests/ui/print_type_sizes/repr_int_c.stdout (renamed from src/test/ui/print_type_sizes/repr_int_c.stdout)0
-rw-r--r--tests/ui/print_type_sizes/uninhabited.rs13
-rw-r--r--tests/ui/print_type_sizes/uninhabited.stdout (renamed from src/test/ui/print_type_sizes/uninhabited.stdout)0
-rw-r--r--tests/ui/print_type_sizes/variants.rs18
-rw-r--r--tests/ui/print_type_sizes/variants.stdout (renamed from src/test/ui/print_type_sizes/variants.stdout)0
-rw-r--r--tests/ui/print_type_sizes/zero-sized-fields.rs (renamed from src/test/ui/print_type_sizes/zero-sized-fields.rs)8
-rw-r--r--tests/ui/print_type_sizes/zero-sized-fields.stdout (renamed from src/test/ui/print_type_sizes/zero-sized-fields.stdout)0
29 files changed, 291 insertions, 35 deletions
diff --git a/src/test/ui/print_type_sizes/anonymous.rs b/tests/ui/print_type_sizes/anonymous.rs
index 2b008ca3b..2b008ca3b 100644
--- a/src/test/ui/print_type_sizes/anonymous.rs
+++ b/tests/ui/print_type_sizes/anonymous.rs
diff --git a/tests/ui/print_type_sizes/async.rs b/tests/ui/print_type_sizes/async.rs
new file mode 100644
index 000000000..1598b0696
--- /dev/null
+++ b/tests/ui/print_type_sizes/async.rs
@@ -0,0 +1,11 @@
+// compile-flags: -Z print-type-sizes --crate-type lib
+// edition:2021
+// build-pass
+// ignore-pass
+
+async fn wait() {}
+
+pub async fn test(arg: [u8; 8192]) {
+ wait().await;
+ drop(arg);
+}
diff --git a/tests/ui/print_type_sizes/async.stdout b/tests/ui/print_type_sizes/async.stdout
new file mode 100644
index 000000000..6e47bb493
--- /dev/null
+++ b/tests/ui/print_type_sizes/async.stdout
@@ -0,0 +1,34 @@
+print-type-size type: `[async fn body@$DIR/async.rs:8:36: 11:2]`: 16386 bytes, alignment: 1 bytes
+print-type-size discriminant: 1 bytes
+print-type-size variant `Suspend0`: 16385 bytes
+print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size field `.arg`: 8192 bytes
+print-type-size field `.__awaitee`: 1 bytes
+print-type-size variant `Unresumed`: 8192 bytes
+print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size variant `Returned`: 8192 bytes
+print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size variant `Panicked`: 8192 bytes
+print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
+print-type-size field `.value`: 8192 bytes
+print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
+print-type-size variant `MaybeUninit`: 8192 bytes
+print-type-size field `.uninit`: 0 bytes
+print-type-size field `.value`: 8192 bytes
+print-type-size type: `[async fn body@$DIR/async.rs:6:17: 6:19]`: 1 bytes, alignment: 1 bytes
+print-type-size discriminant: 1 bytes
+print-type-size variant `Unresumed`: 0 bytes
+print-type-size variant `Returned`: 0 bytes
+print-type-size variant `Panicked`: 0 bytes
+print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async.rs:6:17: 6:19]>`: 1 bytes, alignment: 1 bytes
+print-type-size field `.value`: 1 bytes
+print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async.rs:6:17: 6:19]>`: 1 bytes, alignment: 1 bytes
+print-type-size variant `MaybeUninit`: 1 bytes
+print-type-size field `.uninit`: 0 bytes
+print-type-size field `.value`: 1 bytes
+print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
+print-type-size discriminant: 1 bytes
+print-type-size variant `Ready`: 0 bytes
+print-type-size field `.0`: 0 bytes
+print-type-size variant `Pending`: 0 bytes
diff --git a/tests/ui/print_type_sizes/generator.rs b/tests/ui/print_type_sizes/generator.rs
new file mode 100644
index 000000000..d1cd36274
--- /dev/null
+++ b/tests/ui/print_type_sizes/generator.rs
@@ -0,0 +1,18 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+// ignore-pass
+
+#![feature(generators, generator_trait)]
+
+use std::ops::Generator;
+
+fn generator<const C: usize>(array: [u8; C]) -> impl Generator<Yield = (), Return = ()> {
+ move |()| {
+ yield ();
+ let _ = array;
+ }
+}
+
+pub fn foo() {
+ let _ = generator([0; 8192]);
+}
diff --git a/tests/ui/print_type_sizes/generator.stdout b/tests/ui/print_type_sizes/generator.stdout
new file mode 100644
index 000000000..28d4a6e6c
--- /dev/null
+++ b/tests/ui/print_type_sizes/generator.stdout
@@ -0,0 +1,10 @@
+print-type-size type: `[generator@$DIR/generator.rs:10:5: 10:14]`: 8193 bytes, alignment: 1 bytes
+print-type-size discriminant: 1 bytes
+print-type-size variant `Unresumed`: 8192 bytes
+print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size variant `Returned`: 8192 bytes
+print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size variant `Panicked`: 8192 bytes
+print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
+print-type-size variant `Suspend0`: 8192 bytes
+print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
diff --git a/tests/ui/print_type_sizes/generator_discr_placement.rs b/tests/ui/print_type_sizes/generator_discr_placement.rs
new file mode 100644
index 000000000..1a85fe95b
--- /dev/null
+++ b/tests/ui/print_type_sizes/generator_discr_placement.rs
@@ -0,0 +1,23 @@
+// compile-flags: -Z print-type-sizes --crate-type lib
+// build-pass
+// ignore-pass
+
+// Tests a generator that has its discriminant as the *final* field.
+
+// Avoid emitting panic handlers, like the rest of these tests...
+#![feature(generators)]
+
+pub fn foo() {
+ let a = || {
+ {
+ let w: i32 = 4;
+ yield;
+ drop(w);
+ }
+ {
+ let z: i32 = 7;
+ yield;
+ drop(z);
+ }
+ };
+}
diff --git a/tests/ui/print_type_sizes/generator_discr_placement.stdout b/tests/ui/print_type_sizes/generator_discr_placement.stdout
new file mode 100644
index 000000000..7f8f4ccae
--- /dev/null
+++ b/tests/ui/print_type_sizes/generator_discr_placement.stdout
@@ -0,0 +1,11 @@
+print-type-size type: `[generator@$DIR/generator_discr_placement.rs:11:13: 11:15]`: 8 bytes, alignment: 4 bytes
+print-type-size discriminant: 1 bytes
+print-type-size variant `Suspend0`: 7 bytes
+print-type-size padding: 3 bytes
+print-type-size field `.w`: 4 bytes, alignment: 4 bytes
+print-type-size variant `Suspend1`: 7 bytes
+print-type-size padding: 3 bytes
+print-type-size field `.z`: 4 bytes, alignment: 4 bytes
+print-type-size variant `Unresumed`: 0 bytes
+print-type-size variant `Returned`: 0 bytes
+print-type-size variant `Panicked`: 0 bytes
diff --git a/tests/ui/print_type_sizes/generics.rs b/tests/ui/print_type_sizes/generics.rs
new file mode 100644
index 000000000..05097087d
--- /dev/null
+++ b/tests/ui/print_type_sizes/generics.rs
@@ -0,0 +1,51 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+// ignore-pass
+// ^-- needed because `--pass check` does not emit the output needed.
+// FIXME: consider using an attribute instead of side-effects.
+
+// This file illustrates how generics are handled: types have to be
+// monomorphized, in the MIR of the original function in which they
+// occur, to have their size reported.
+
+#[derive(Copy, Clone)]
+pub struct Pair<T> {
+ _car: T,
+ _cdr: T,
+}
+
+impl<T> Pair<T> {
+ fn new(a: T, d: T) -> Self {
+ Pair {
+ _car: a,
+ _cdr: d,
+ }
+ }
+}
+
+#[derive(Copy, Clone)]
+pub struct SevenBytes([u8; 7]);
+pub struct FiftyBytes([u8; 50]);
+
+pub struct ZeroSized;
+
+impl SevenBytes {
+ fn new() -> Self { SevenBytes([0; 7]) }
+}
+
+impl FiftyBytes {
+ fn new() -> Self { FiftyBytes([0; 50]) }
+}
+
+pub fn f1<T:Copy>(x: T) {
+ let _v: Pair<T> = Pair::new(x, x);
+ let _v2: Pair<FiftyBytes> =
+ Pair::new(FiftyBytes::new(), FiftyBytes::new());
+}
+
+pub fn start() {
+ let _b: Pair<u8> = Pair::new(0, 0);
+ let _s: Pair<SevenBytes> = Pair::new(SevenBytes::new(), SevenBytes::new());
+ let ref _z: ZeroSized = ZeroSized;
+ f1::<SevenBytes>(SevenBytes::new());
+}
diff --git a/src/test/ui/print_type_sizes/generics.stdout b/tests/ui/print_type_sizes/generics.stdout
index 0f02f3979..0f02f3979 100644
--- a/src/test/ui/print_type_sizes/generics.stdout
+++ b/tests/ui/print_type_sizes/generics.stdout
diff --git a/tests/ui/print_type_sizes/multiple_types.rs b/tests/ui/print_type_sizes/multiple_types.rs
new file mode 100644
index 000000000..915903892
--- /dev/null
+++ b/tests/ui/print_type_sizes/multiple_types.rs
@@ -0,0 +1,13 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+
+// This file illustrates that when multiple structural types occur in
+// a function, every one of them is included in the output.
+
+pub struct SevenBytes([u8; 7]);
+pub struct FiftyBytes([u8; 50]);
+
+pub enum Enum {
+ Small(SevenBytes),
+ Large(FiftyBytes),
+}
diff --git a/src/test/ui/print_type_sizes/multiple_types.stdout b/tests/ui/print_type_sizes/multiple_types.stdout
index 641188154..641188154 100644
--- a/src/test/ui/print_type_sizes/multiple_types.stdout
+++ b/tests/ui/print_type_sizes/multiple_types.stdout
diff --git a/src/test/ui/print_type_sizes/niche-filling.rs b/tests/ui/print_type_sizes/niche-filling.rs
index 0716cee21..5e620f248 100644
--- a/src/test/ui/print_type_sizes/niche-filling.rs
+++ b/tests/ui/print_type_sizes/niche-filling.rs
@@ -1,4 +1,4 @@
-// compile-flags: -Z print-type-sizes
+// compile-flags: -Z print-type-sizes --crate-type=lib
// build-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
@@ -14,7 +14,6 @@
// aligned (while on most it is 8-byte aligned) and so the resulting
// padding and overall computed sizes can be quite different.
-#![feature(start)]
#![feature(rustc_attrs)]
#![allow(dead_code)]
@@ -56,7 +55,7 @@ pub struct NestedNonZero {
impl Default for NestedNonZero {
fn default() -> Self {
- NestedNonZero { pre: 0, val: NonZeroU32::new(1).unwrap(), post: 0 }
+ NestedNonZero { pre: 0, val: unsafe { NonZeroU32::new_unchecked(1) }, post: 0 }
}
}
@@ -76,8 +75,7 @@ pub union Union2<A: Copy, B: Copy> {
b: B,
}
-#[start]
-fn start(_: isize, _: *const *const u8) -> isize {
+pub fn test() {
let _x: MyOption<NonZeroU32> = Default::default();
let _y: EmbeddedDiscr = Default::default();
let _z: MyOption<IndirectNonZero> = Default::default();
@@ -96,6 +94,4 @@ fn start(_: isize, _: *const *const u8) -> isize {
// ...even when theoretically possible.
let _j: MyOption<Union1<NonZeroU32>> = Default::default();
let _k: MyOption<Union2<NonZeroU32, NonZeroU32>> = Default::default();
-
- 0
}
diff --git a/src/test/ui/print_type_sizes/niche-filling.stdout b/tests/ui/print_type_sizes/niche-filling.stdout
index d1753c26c..d1753c26c 100644
--- a/src/test/ui/print_type_sizes/niche-filling.stdout
+++ b/tests/ui/print_type_sizes/niche-filling.stdout
diff --git a/src/test/ui/print_type_sizes/no_duplicates.rs b/tests/ui/print_type_sizes/no_duplicates.rs
index e45e4794a..2ec5d9e64 100644
--- a/src/test/ui/print_type_sizes/no_duplicates.rs
+++ b/tests/ui/print_type_sizes/no_duplicates.rs
@@ -1,4 +1,4 @@
-// compile-flags: -Z print-type-sizes
+// compile-flags: -Z print-type-sizes --crate-type=lib
// build-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
@@ -8,16 +8,12 @@
// (even if multiple functions), it is only printed once in the
// print-type-sizes output.
-#![feature(start)]
-
pub struct SevenBytes([u8; 7]);
pub fn f1() {
let _s: SevenBytes = SevenBytes([0; 7]);
}
-#[start]
-fn start(_: isize, _: *const *const u8) -> isize {
+pub fn test() {
let _s: SevenBytes = SevenBytes([0; 7]);
- 0
}
diff --git a/src/test/ui/print_type_sizes/no_duplicates.stdout b/tests/ui/print_type_sizes/no_duplicates.stdout
index 50180f356..50180f356 100644
--- a/src/test/ui/print_type_sizes/no_duplicates.stdout
+++ b/tests/ui/print_type_sizes/no_duplicates.stdout
diff --git a/tests/ui/print_type_sizes/packed.rs b/tests/ui/print_type_sizes/packed.rs
new file mode 100644
index 000000000..5ddfe4bf4
--- /dev/null
+++ b/tests/ui/print_type_sizes/packed.rs
@@ -0,0 +1,59 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+// ignore-pass
+// ^-- needed because `--pass check` does not emit the output needed.
+// FIXME: consider using an attribute instead of side-effects.
+
+// This file illustrates how packing is handled; it should cause
+// the elimination of padding that would normally be introduced
+// to satisfy alignment desirata.
+//
+// It avoids using u64/i64 because on some targets that is only 4-byte
+// aligned (while on most it is 8-byte aligned) and so the resulting
+// padding and overall computed sizes can be quite different.
+
+#![allow(dead_code)]
+
+#[derive(Default)]
+#[repr(packed)]
+pub struct Packed1 {
+ a: u8,
+ b: u8,
+ g: i32,
+ c: u8,
+ h: i16,
+ d: u8,
+}
+
+#[derive(Default)]
+#[repr(packed(2))]
+pub struct Packed2 {
+ a: u8,
+ b: u8,
+ g: i32,
+ c: u8,
+ h: i16,
+ d: u8,
+}
+
+#[derive(Default)]
+#[repr(packed(2))]
+#[repr(C)]
+pub struct Packed2C {
+ a: u8,
+ b: u8,
+ g: i32,
+ c: u8,
+ h: i16,
+ d: u8,
+}
+
+#[derive(Default)]
+pub struct Padded {
+ a: u8,
+ b: u8,
+ g: i32,
+ c: u8,
+ h: i16,
+ d: u8,
+}
diff --git a/src/test/ui/print_type_sizes/packed.stdout b/tests/ui/print_type_sizes/packed.stdout
index 58e1bac9e..58e1bac9e 100644
--- a/src/test/ui/print_type_sizes/packed.stdout
+++ b/tests/ui/print_type_sizes/packed.stdout
diff --git a/src/test/ui/print_type_sizes/padding.rs b/tests/ui/print_type_sizes/padding.rs
index d1acad16d..f41c677dc 100644
--- a/src/test/ui/print_type_sizes/padding.rs
+++ b/tests/ui/print_type_sizes/padding.rs
@@ -1,4 +1,4 @@
-// compile-flags: -Z print-type-sizes
+// compile-flags: -Z print-type-sizes --crate-type=lib
// build-pass
// This file illustrates how padding is handled: alignment
@@ -9,7 +9,6 @@
// aligned (while on most it is 8-byte aligned) and so the resulting
// padding and overall computed sizes can be quite different.
-#![feature(start)]
#![allow(dead_code)]
struct S {
@@ -27,8 +26,3 @@ enum E2 {
A(i8, i32),
B(S),
}
-
-#[start]
-fn start(_: isize, _: *const *const u8) -> isize {
- 0
-}
diff --git a/src/test/ui/print_type_sizes/padding.stdout b/tests/ui/print_type_sizes/padding.stdout
index 9afdf7624..9afdf7624 100644
--- a/src/test/ui/print_type_sizes/padding.stdout
+++ b/tests/ui/print_type_sizes/padding.stdout
diff --git a/src/test/ui/print_type_sizes/repr-align.rs b/tests/ui/print_type_sizes/repr-align.rs
index 07544935b..0bd11ebc9 100644
--- a/src/test/ui/print_type_sizes/repr-align.rs
+++ b/tests/ui/print_type_sizes/repr-align.rs
@@ -1,4 +1,4 @@
-// compile-flags: -Z print-type-sizes
+// compile-flags: -Z print-type-sizes --crate-type=lib
// build-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
@@ -11,7 +11,7 @@
// It avoids using u64/i64 because on some targets that is only 4-byte
// aligned (while on most it is 8-byte aligned) and so the resulting
// padding and overall computed sizes can be quite different.
-#![feature(start)]
+
#![allow(dead_code)]
#[repr(align(16))]
@@ -24,15 +24,9 @@ enum E {
}
#[derive(Default)]
-struct S {
+pub struct S {
a: i32,
b: i32,
c: A,
d: i8,
}
-
-#[start]
-fn start(_: isize, _: *const *const u8) -> isize {
- let _s: S = Default::default();
- 0
-}
diff --git a/src/test/ui/print_type_sizes/repr-align.stdout b/tests/ui/print_type_sizes/repr-align.stdout
index 33671bd8e..33671bd8e 100644
--- a/src/test/ui/print_type_sizes/repr-align.stdout
+++ b/tests/ui/print_type_sizes/repr-align.stdout
diff --git a/tests/ui/print_type_sizes/repr_int_c.rs b/tests/ui/print_type_sizes/repr_int_c.rs
new file mode 100644
index 000000000..6b103776a
--- /dev/null
+++ b/tests/ui/print_type_sizes/repr_int_c.rs
@@ -0,0 +1,19 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+
+// This test makes sure that the tag is not grown for `repr(C)` or `repr(u8)`
+// variants (see https://github.com/rust-lang/rust/issues/50098 for the original bug).
+
+#![allow(dead_code)]
+
+#[repr(C, u8)]
+enum ReprCu8 {
+ A(u16),
+ B,
+}
+
+#[repr(u8)]
+enum Repru8 {
+ A(u16),
+ B,
+}
diff --git a/src/test/ui/print_type_sizes/repr_int_c.stdout b/tests/ui/print_type_sizes/repr_int_c.stdout
index 254b3c7a8..254b3c7a8 100644
--- a/src/test/ui/print_type_sizes/repr_int_c.stdout
+++ b/tests/ui/print_type_sizes/repr_int_c.stdout
diff --git a/tests/ui/print_type_sizes/uninhabited.rs b/tests/ui/print_type_sizes/uninhabited.rs
new file mode 100644
index 000000000..86fab7b50
--- /dev/null
+++ b/tests/ui/print_type_sizes/uninhabited.rs
@@ -0,0 +1,13 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+// ignore-pass
+// ^-- needed because `--pass check` does not emit the output needed.
+// FIXME: consider using an attribute instead of side-effects.
+
+#![feature(never_type)]
+
+pub fn test() {
+ let _x: Option<!> = None;
+ let _y: Result<u32, !> = Ok(42);
+ let _z: Result<!, !> = loop {};
+}
diff --git a/src/test/ui/print_type_sizes/uninhabited.stdout b/tests/ui/print_type_sizes/uninhabited.stdout
index 5eb5384bc..5eb5384bc 100644
--- a/src/test/ui/print_type_sizes/uninhabited.stdout
+++ b/tests/ui/print_type_sizes/uninhabited.stdout
diff --git a/tests/ui/print_type_sizes/variants.rs b/tests/ui/print_type_sizes/variants.rs
new file mode 100644
index 000000000..5a3020520
--- /dev/null
+++ b/tests/ui/print_type_sizes/variants.rs
@@ -0,0 +1,18 @@
+// compile-flags: -Z print-type-sizes --crate-type=lib
+// build-pass
+
+// This file illustrates two things:
+//
+// 1. Only types that appear in a monomorphized function appear in the
+// print-type-sizes output, and
+//
+// 2. For an enum, the print-type-sizes output will also include the
+// size of each variant.
+
+pub struct SevenBytes([u8; 7]);
+pub struct FiftyBytes([u8; 50]);
+
+pub enum Enum {
+ Small(SevenBytes),
+ Large(FiftyBytes),
+}
diff --git a/src/test/ui/print_type_sizes/variants.stdout b/tests/ui/print_type_sizes/variants.stdout
index 641188154..641188154 100644
--- a/src/test/ui/print_type_sizes/variants.stdout
+++ b/tests/ui/print_type_sizes/variants.stdout
diff --git a/src/test/ui/print_type_sizes/zero-sized-fields.rs b/tests/ui/print_type_sizes/zero-sized-fields.rs
index e02a33109..09415824d 100644
--- a/src/test/ui/print_type_sizes/zero-sized-fields.rs
+++ b/tests/ui/print_type_sizes/zero-sized-fields.rs
@@ -1,12 +1,10 @@
-// compile-flags: -Z print-type-sizes
+// compile-flags: -Z print-type-sizes --crate-type=lib
// build-pass
// ignore-pass
// At one point, zero-sized fields such as those in this file were causing
// incorrect output from `-Z print-type-sizes`.
-#![feature(start)]
-
struct S1 {
x: u32,
y: u32,
@@ -28,8 +26,7 @@ struct S5<TagW, TagZ> {
tagz: TagZ,
}
-#[start]
-fn start(_: isize, _: *const *const u8) -> isize {
+pub fn test() {
let _s1: S1 = S1 { x: 0, y: 0, tag: () };
let _s5: S5<(), Empty> = S5 {
@@ -43,5 +40,4 @@ fn start(_: isize, _: *const *const u8) -> isize {
z: 4,
tagz: Empty {},
};
- 0
}
diff --git a/src/test/ui/print_type_sizes/zero-sized-fields.stdout b/tests/ui/print_type_sizes/zero-sized-fields.stdout
index 72f59c4bb..72f59c4bb 100644
--- a/src/test/ui/print_type_sizes/zero-sized-fields.stdout
+++ b/tests/ui/print_type_sizes/zero-sized-fields.stdout