mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 20:46:49 +00:00
rustdoc: Note in a type's layout/size if it is uninhabited
This commit is contained in:
parent
13471d3b20
commit
7520155e4e
|
@ -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>)"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue