2021-04-12 21:42:26 -05:00
|
|
|
// compile-flags: --show-type-layout -Z unstable-options
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.Foo.html 'Size: '
|
|
|
|
// @hasraw - ' bytes'
|
2022-07-26 05:45:16 -05:00
|
|
|
// @has - '//*[@id="layout"]/a[@href="#layout"]' ''
|
2021-04-12 21:06:15 -05:00
|
|
|
pub struct Foo {
|
|
|
|
pub a: usize,
|
|
|
|
b: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/enum.Bar.html 'Size: '
|
|
|
|
// @hasraw - ' bytes'
|
2021-04-12 21:06:15 -05:00
|
|
|
pub enum Bar<'a> {
|
|
|
|
A(String),
|
|
|
|
B(&'a str, (std::collections::HashMap<String, usize>, Foo)),
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/union.Baz.html 'Size: '
|
|
|
|
// @hasraw - ' bytes'
|
2021-04-12 21:06:15 -05:00
|
|
|
pub union Baz {
|
|
|
|
a: &'static str,
|
|
|
|
b: usize,
|
|
|
|
c: &'static [u8],
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.X.html 'Size: '
|
|
|
|
// @hasraw - ' bytes'
|
2021-04-12 21:06:15 -05:00
|
|
|
pub struct X(usize);
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.Y.html 'Size: '
|
|
|
|
// @hasraw - '1 byte'
|
2022-08-11 23:44:07 -05:00
|
|
|
// @!hasraw - ' bytes'
|
2021-04-12 21:06:15 -05:00
|
|
|
pub struct Y(u8);
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.Z.html 'Size: '
|
|
|
|
// @hasraw - '0 bytes'
|
2021-04-27 12:38:12 -05:00
|
|
|
pub struct Z;
|
|
|
|
|
2021-04-27 19:11:58 -05:00
|
|
|
// We can't compute layout for generic types.
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters'
|
2022-08-11 23:44:07 -05:00
|
|
|
// @!hasraw - 'Size: '
|
2021-04-12 21:06:15 -05:00
|
|
|
pub struct Generic<T>(T);
|
|
|
|
|
2021-04-27 19:11:58 -05:00
|
|
|
// We *can*, however, compute layout for types that are only generic over lifetimes,
|
|
|
|
// because lifetimes are a type-system construct.
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.GenericLifetimes.html 'Size: '
|
|
|
|
// @hasraw - ' bytes'
|
2021-04-27 19:11:58 -05:00
|
|
|
pub struct GenericLifetimes<'a>(&'a str);
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/struct.Unsized.html 'Size: '
|
|
|
|
// @hasraw - '(unsized)'
|
2021-04-12 21:06:15 -05:00
|
|
|
pub struct Unsized([u8]);
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/type.TypeAlias.html 'Size: '
|
|
|
|
// @hasraw - ' bytes'
|
2021-12-08 18:05:31 -06:00
|
|
|
pub type TypeAlias = X;
|
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/type.GenericTypeAlias.html 'Size: '
|
|
|
|
// @hasraw - '8 bytes'
|
2021-12-08 18:05:31 -06:00
|
|
|
pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>);
|
|
|
|
|
|
|
|
// Regression test for the rustdoc equivalent of #85103.
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.'
|
2021-12-08 18:05:31 -06:00
|
|
|
pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>;
|
|
|
|
|
2022-08-11 23:44:07 -05:00
|
|
|
// @!hasraw type_layout/trait.MyTrait.html 'Size: '
|
2021-04-12 21:06:15 -05:00
|
|
|
pub trait MyTrait {}
|
2021-06-13 12:49:37 -05:00
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/enum.Variants.html 'Size: '
|
|
|
|
// @hasraw - '2 bytes'
|
|
|
|
// @hasraw - '<code>A</code>: 0 bytes'
|
|
|
|
// @hasraw - '<code>B</code>: 1 byte'
|
2021-06-13 12:49:37 -05:00
|
|
|
pub enum Variants {
|
|
|
|
A,
|
|
|
|
B(u8),
|
|
|
|
}
|
2021-09-06 02:09:32 -05:00
|
|
|
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw type_layout/enum.WithNiche.html 'Size: '
|
2021-09-06 02:09:32 -05:00
|
|
|
// @has - //p '4 bytes'
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw - '<code>None</code>: 0 bytes'
|
|
|
|
// @hasraw - '<code>Some</code>: 4 bytes'
|
2021-09-06 02:09:32 -05:00
|
|
|
pub enum WithNiche {
|
|
|
|
None,
|
|
|
|
Some(std::num::NonZeroU32),
|
|
|
|
}
|