2021-04-12 19:42:26 -07:00
//@ compile-flags: --show-type-layout -Z unstable-options
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.Foo.html 'Size: '
//@ hasraw - ' bytes'
//@ has - '//*[@id="layout"]/a[@href="#layout"]' ''
2021-04-12 19:06:15 -07:00
pub struct Foo {
pub a : usize ,
b : Vec < String > ,
}
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/enum.Bar.html 'Size: '
//@ hasraw - ' bytes'
2021-04-12 19:06:15 -07:00
pub enum Bar < ' a > {
A ( String ) ,
B ( & ' a str , ( std ::collections ::HashMap < String , usize > , Foo ) ) ,
}
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/union.Baz.html 'Size: '
//@ hasraw - ' bytes'
2021-04-12 19:06:15 -07:00
pub union Baz {
a : & 'static str ,
b : usize ,
c : & 'static [ u8 ] ,
}
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.X.html 'Size: '
//@ hasraw - ' bytes'
2021-04-12 19:06:15 -07:00
pub struct X ( usize ) ;
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.Y.html 'Size: '
//@ hasraw - '1 byte'
//@ !hasraw - ' bytes'
2021-04-12 19:06:15 -07:00
pub struct Y ( u8 ) ;
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.Z.html 'Size: '
//@ hasraw - '0 bytes'
2021-04-27 10:38:12 -07:00
pub struct Z ;
2021-04-27 17:11:58 -07:00
// We can't compute layout for generic types.
2025-01-06 11:39:07 +01:00
//@ hasraw type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters.'
//@ hasraw type_layout/struct.Generic.html 'Layout can only be computed for concrete, fully-instantiated types.'
2024-06-21 14:03:08 +02:00
//@ !hasraw - 'Size: '
2021-04-12 19:06:15 -07:00
pub struct Generic < T > ( T ) ;
2021-04-27 17:11:58 -07:00
// We *can*, however, compute layout for types that are only generic over lifetimes,
// because lifetimes are a type-system construct.
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.GenericLifetimes.html 'Size: '
//@ hasraw - ' bytes'
2021-04-27 17:11:58 -07:00
pub struct GenericLifetimes < ' a > ( & ' a str ) ;
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.Unsized.html 'Size: '
//@ hasraw - '(unsized)'
2021-04-12 19:06:15 -07:00
pub struct Unsized ( [ u8 ] ) ;
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/type.TypeAlias.html 'Size: '
//@ hasraw - ' bytes'
2021-12-08 16:05:31 -08:00
pub type TypeAlias = X ;
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/type.GenericTypeAlias.html 'Size: '
//@ hasraw - '8 bytes'
2021-12-08 16:05:31 -08:00
pub type GenericTypeAlias = ( Generic < ( u32 , ( ) ) > , Generic < u32 > ) ;
// Regression test for the rustdoc equivalent of #85103.
2025-05-09 18:47:25 +02:00
//@ hasraw type_layout/type.Edges.html 'Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.'
2021-12-08 16:05:31 -08:00
pub type Edges < ' a , E > = std ::borrow ::Cow < ' a , [ E ] > ;
2024-06-21 14:03:08 +02:00
//@ !hasraw type_layout/trait.MyTrait.html 'Size: '
2021-04-12 19:06:15 -07:00
pub trait MyTrait { }
2021-06-14 01:49:37 +08:00
2024-06-21 14:03:08 +02: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-14 01:49:37 +08:00
pub enum Variants {
A ,
B ( u8 ) ,
}
2021-09-06 07:09:32 +00:00
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/enum.WithNiche.html 'Size: '
//@ has - //p '4 bytes'
//@ hasraw - '<code>None</code>: 0 bytes'
//@ hasraw - '<code>Some</code>: 4 bytes'
2021-09-06 07:09:32 +00:00
pub enum WithNiche {
None ,
2024-02-22 14:59:52 +01:00
Some ( std ::num ::NonZero < u32 > ) ,
2021-09-06 07:09:32 +00:00
}
2023-03-04 12:07:29 +00:00
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/enum.Uninhabited.html 'Size: '
2024-12-26 23:41:58 +01:00
//@ hasraw - '0 bytes (<a href="{{channel}}/reference/glossary.html#uninhabited">uninhabited</a>)'
2023-03-04 12:07:29 +00:00
pub enum Uninhabited { }
2024-06-21 14:03:08 +02:00
//@ hasraw type_layout/struct.Uninhabited2.html 'Size: '
2024-12-26 23:41:58 +01:00
//@ hasraw - '8 bytes (<a href="{{channel}}/reference/glossary.html#uninhabited">uninhabited</a>)'
2023-03-04 12:07:29 +00:00
pub struct Uninhabited2 ( std ::convert ::Infallible , u64 ) ;
2025-01-06 11:39:07 +01:00
pub trait Project { type Assoc ; }
// We can't compute layout. A `LayoutError::Unknown` is returned.
//@ hasraw type_layout/struct.Unknown.html 'Unable to compute type layout.'
//@ !hasraw - 'Size: '
pub struct Unknown ( < ( ) as Project > ::Assoc ) where for < ' a > ( ) : Project ;