Rollup merge of #108734 - clubby789:rustdoc-layout-uninhabited, r=GuillaumeGomez

rustdoc: Note in a type's layout/size if it is uninhabited

Closes #87008

![image](https://user-images.githubusercontent.com/13556931/222900244-8e326d51-8d3b-4700-a935-96830179e2e9.png)
This commit is contained in:
Matthias Krüger 2023-03-04 20:48:19 +01:00 committed by GitHub
commit 99fad38b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -1839,6 +1839,12 @@ fn write_size_of_layout(w: &mut Buffer, layout: &LayoutS, tag_size: u64) {
} else {
let size = layout.size.bytes() - tag_size;
write!(w, "{size} byte{pl}", pl = if size == 1 { "" } else { "s" },);
if layout.abi.is_uninhabited() {
write!(
w,
" (<a href=\"https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited\">uninhabited</a>)"
);
}
}
}

View File

@ -83,3 +83,11 @@ pub enum WithNiche {
None,
Some(std::num::NonZeroU32),
}
// @hasraw type_layout/enum.Uninhabited.html 'Size: '
// @hasraw - '0 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)'
pub enum Uninhabited {}
// @hasraw type_layout/struct.Uninhabited2.html 'Size: '
// @hasraw - '8 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)'
pub struct Uninhabited2(std::convert::Infallible, u64);