1 // compile-flags: --show-type-layout -Z unstable-options
3 // @has type_layout/struct.Foo.html 'Size: '
10 // @has type_layout/enum.Bar.html 'Size: '
14 B(&'a str, (std::collections::HashMap<String, usize>, Foo)),
17 // @has type_layout/union.Baz.html 'Size: '
25 // @has type_layout/struct.X.html 'Size: '
29 // @has type_layout/struct.Y.html 'Size: '
34 // @has type_layout/struct.Z.html 'Size: '
38 // We can't compute layout for generic types.
39 // @has type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters'
41 pub struct Generic<T>(T);
43 // We *can*, however, compute layout for types that are only generic over lifetimes,
44 // because lifetimes are a type-system construct.
45 // @has type_layout/struct.GenericLifetimes.html 'Size: '
47 pub struct GenericLifetimes<'a>(&'a str);
49 // @has type_layout/struct.Unsized.html 'Size: '
51 pub struct Unsized([u8]);
53 // @has type_layout/type.TypeAlias.html 'Size: '
55 pub type TypeAlias = X;
57 // @has type_layout/type.GenericTypeAlias.html 'Size: '
59 pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>);
61 // Regression test for the rustdoc equivalent of #85103.
62 // @has type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.'
63 pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>;
65 // @!has type_layout/trait.MyTrait.html 'Size: '
68 // @has type_layout/enum.Variants.html 'Size: '
70 // @has - '<code>A</code>: 0 bytes'
71 // @has - '<code>B</code>: 1 byte'
77 // @has type_layout/enum.WithNiche.html 'Size: '
78 // @has - //p '4 bytes'
79 // @has - '<code>None</code>: 0 bytes'
80 // @has - '<code>Some</code>: 4 bytes'
83 Some(std::num::NonZeroU32),