-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #83501 - camelid:rustdoc-layout, r=jyn514,GuillaumeGomez
rustdoc: Add unstable CLI option to show basic type layout information Closes #75988. Right now it just shows the size.
- Loading branch information
Showing
7 changed files
with
145 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Tests that `--show-type-layout` is required in order to show layout info. | ||
|
||
// @!has type_layout_flag_required/struct.Foo.html 'Size: ' | ||
pub struct Foo(usize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// compile-flags: --show-type-layout -Z unstable-options | ||
|
||
// @has type_layout/struct.Foo.html 'Size: ' | ||
// @has - ' bytes' | ||
pub struct Foo { | ||
pub a: usize, | ||
b: Vec<String>, | ||
} | ||
|
||
// @has type_layout/enum.Bar.html 'Size: ' | ||
// @has - ' bytes' | ||
pub enum Bar<'a> { | ||
A(String), | ||
B(&'a str, (std::collections::HashMap<String, usize>, Foo)), | ||
} | ||
|
||
// @has type_layout/union.Baz.html 'Size: ' | ||
// @has - ' bytes' | ||
pub union Baz { | ||
a: &'static str, | ||
b: usize, | ||
c: &'static [u8], | ||
} | ||
|
||
// @has type_layout/struct.X.html 'Size: ' | ||
// @has - ' bytes' | ||
pub struct X(usize); | ||
|
||
// @has type_layout/struct.Y.html 'Size: ' | ||
// @has - '1 byte' | ||
// @!has - ' bytes' | ||
pub struct Y(u8); | ||
|
||
// @has type_layout/struct.Z.html 'Size: ' | ||
// @has - '0 bytes' | ||
pub struct Z; | ||
|
||
// We can't compute layout for generic types. | ||
// @has type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters' | ||
// @!has - 'Size: ' | ||
pub struct Generic<T>(T); | ||
|
||
// We *can*, however, compute layout for types that are only generic over lifetimes, | ||
// because lifetimes are a type-system construct. | ||
// @has type_layout/struct.GenericLifetimes.html 'Size: ' | ||
// @has - ' bytes' | ||
pub struct GenericLifetimes<'a>(&'a str); | ||
|
||
// @has type_layout/struct.Unsized.html 'Size: ' | ||
// @has - '(unsized)' | ||
pub struct Unsized([u8]); | ||
|
||
// @!has type_layout/trait.MyTrait.html 'Size: ' | ||
pub trait MyTrait {} |