]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/type-layout.rs
Auto merge of #82624 - ojeda:rwlock-example-deadlock, r=JohnTitor
[rust.git] / src / test / rustdoc / type-layout.rs
1 // compile-flags: --show-type-layout -Z unstable-options
2
3 // @has type_layout/struct.Foo.html 'Size: '
4 // @has - ' bytes'
5 pub struct Foo {
6     pub a: usize,
7     b: Vec<String>,
8 }
9
10 // @has type_layout/enum.Bar.html 'Size: '
11 // @has - ' bytes'
12 pub enum Bar<'a> {
13     A(String),
14     B(&'a str, (std::collections::HashMap<String, usize>, Foo)),
15 }
16
17 // @has type_layout/union.Baz.html 'Size: '
18 // @has - ' bytes'
19 pub union Baz {
20     a: &'static str,
21     b: usize,
22     c: &'static [u8],
23 }
24
25 // @has type_layout/struct.X.html 'Size: '
26 // @has - ' bytes'
27 pub struct X(usize);
28
29 // @has type_layout/struct.Y.html 'Size: '
30 // @has - '1 byte'
31 // @!has - ' bytes'
32 pub struct Y(u8);
33
34 // @has type_layout/struct.Z.html 'Size: '
35 // @has - '0 bytes'
36 pub struct Z;
37
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'
40 // @!has - 'Size: '
41 pub struct Generic<T>(T);
42
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: '
46 // @has - ' bytes'
47 pub struct GenericLifetimes<'a>(&'a str);
48
49 // @has type_layout/struct.Unsized.html 'Size: '
50 // @has - '(unsized)'
51 pub struct Unsized([u8]);
52
53 // @!has type_layout/trait.MyTrait.html 'Size: '
54 pub trait MyTrait {}