Skip to content
Open
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
22 changes: 22 additions & 0 deletions src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,30 @@ r[glossary.uninhabited]

A type is uninhabited if it has no constructors and therefore can never be instantiated. An uninhabited type is "empty" in the sense that there are no values of the type. The canonical example of an uninhabited type is the [never type] `!`, or an enum with no variants `enum Never { }`. Opposite of [Inhabited](#inhabited).

r[glossary.zst]
### Zero-sized type (ZST)

A type is zero-sized (a ZST) if its size is 0. Such types have only one possible value. Examples include:
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such types have only one possible value.

We may declare the never type (i.e., the empty type) to be a ZST. So it may be more correct to say that a ZST has at most one possible value.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be added even before the stabilization of the never type?


- The [unit type] (see [layout.tuple.unit]).
- [Arrays] of zero-sized types (see [layout.array]).
- [Unions] of zero-sized types (see [items.union.common-storage]).

```rust
# use core::mem::size_of;
union U {
f1: (),
f2: [(); 10],
}
assert_eq!(0, size_of::<()>());
assert_eq!(0, size_of::<[(); 10]>());
assert_eq!(0, size_of::<U>());
```

[`extern` blocks]: items.extern
[`extern fn`]: items.fn.extern
[alignment]: type-layout.md#size-and-alignment
[arrays]: type.array
[associated item]: #associated-item
[attributes]: attributes.md
[*entity*]: names.md
Expand Down Expand Up @@ -252,5 +273,6 @@ A type is uninhabited if it has no constructors and therefore can never be insta
[types]: types.md
[undefined-behavior]: behavior-considered-undefined.md
[unions]: items/unions.md
[unit type]: type.tuple.unit
[variable bindings]: patterns.md
[visibility rules]: visibility-and-privacy.md
Loading