Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ r[glossary.zst]
A type is zero sized (a ZST) if its size is 0. Such types have at most one possible value. Examples include:

- The [unit type] (see [layout.tuple.unit]).
- The [never type] `!` (see [type.never.layout]).
- [Function items] (see [type.fn-item.intro]).
- The constructors of [tuple-like structs] (see [type.fn-item.intro]).
- The constructors of [tuple-like enum variants] (see [type.fn-item.intro]).
Expand Down
2 changes: 2 additions & 0 deletions src/type-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The size of most primitives is given in this table.
| `f32` | 4 |
| `f64` | 8 |
| `char` | 4 |
| [`!`][never-type] | 0 |

r[layout.primitive.size-minimum]
`usize` and `isize` have a size big enough to contain every address on the target platform. For example, on a 32 bit target, this is 4 bytes, and on a 64 bit target, this is 8 bytes.
Expand Down Expand Up @@ -723,3 +724,4 @@ Because this representation delegates type layout to another type, it cannot be
[unit-struct-like variant]: EnumVariant
[`Layout`]: std::alloc::Layout
[uninhabited]: glossary.uninhabited
[never-type]: types/never.md
4 changes: 4 additions & 0 deletions src/types/never.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ NeverType -> `!`
r[type.never.coercion]
Expressions of type `!` can be coerced into any type.


r[type.never.layout]
The `!` type has a size of 0 and an alignment of 1.

> [!NOTE]
> The standard library type [`Infallible`] is a type alias for `!`.

Expand Down
Loading