Skip to content

Glossary: add new entry documenting zero-sized types#2203

Open
DanielEScherzer wants to merge 2 commits intorust-lang:masterfrom
DanielEScherzer:glossary-zst
Open

Glossary: add new entry documenting zero-sized types#2203
DanielEScherzer wants to merge 2 commits intorust-lang:masterfrom
DanielEScherzer:glossary-zst

Conversation

@DanielEScherzer
Copy link
Copy Markdown
Contributor

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Mar 10, 2026
@DanielEScherzer

This comment was marked as resolved.

@rustbot

This comment was marked as resolved.

@rustbot rustbot added A-glossary Area: glossary New Content Missing features or aspects of language not currently documented. labels Mar 10, 2026
@DanielEScherzer DanielEScherzer force-pushed the glossary-zst branch 6 times, most recently from 1e87ac7 to a46e8fa Compare April 14, 2026 19:20
Comment thread src/glossary.md Outdated
@traviscross traviscross removed the New Content Missing features or aspects of language not currently documented. label Apr 19, 2026
Comment thread src/glossary.md Outdated
Comment thread src/glossary.md
@DanielEScherzer DanielEScherzer force-pushed the glossary-zst branch 4 times, most recently from 13ef3ed to 6164e1f Compare April 19, 2026 20:22
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@DanielEScherzer DanielEScherzer force-pushed the glossary-zst branch 4 times, most recently from f3db8e1 to be0b57a Compare April 28, 2026 19:25
Comment thread src/glossary.md
# use core::mem::{size_of, size_of_val};
fn f() {}
struct S(u8);
enum E{ V(u8) }
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 29, 2026

Choose a reason for hiding this comment

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

Please add the missing space here.

View changes since the review

Comment thread src/glossary.md
Comment on lines +221 to +222
- The constructors of tuple-like structs (see [type.fn-item.intro]).
- The constructors of tuple-like enum variants (see [type.fn-item.intro]).
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 29, 2026

Choose a reason for hiding this comment

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

Please link "tuple-like structs" and "tuple-like enum variants".

View changes since the review

Comment thread src/glossary.md
Comment on lines +223 to +224
- `#[repr(C)]` structs with no fields ([unit-like structs]) or where all fields are zero-sized (see [layout.repr.c.struct.size-field-offset]).
- `#[repr(transparent)]` structs with no fields ([unit-like structs]) or where all fields are zero-sized (see [layout.repr.transparent.layout-abi]).
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 29, 2026

Choose a reason for hiding this comment

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

In prose, we'd just say "repr(C) struct" rather than giving the attribute syntax.

View changes since the review

Comment thread src/glossary.md
assert_eq!(0, size_of_val(&f));
// Note that here we are checking the size of the constructors, *not* the
// underlying type, for `S` and `E::V`. The constructors just have the same
// names as the types.
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 29, 2026

Choose a reason for hiding this comment

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

This could use some rewording. This is value position, so it's syntactically clear the name doesn't refer here to a type. Also, E::V isn't a type, so it's not correct to say that the constructors have the same name as the types.

Since the corresponding values couldn't be constructed in this way (due to needing arguments), it might be OK to just drop this comment.

View changes since the review

Comment on lines +249 to 252
[zero-sized]: glossary.zst
[Tuples]: types/tuple.md
[Type parameters]: types/parameters.md
[variance]: subtyping.md#variance
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 29, 2026

Choose a reason for hiding this comment

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

The Reference isn't perfecly consistent about this, but in this case, the sorting is insensitive to case.

View changes since the review

Comment thread src/type-layout.md
Comment on lines +564 to +567
[zero-sized]: glossary.zst
[zero-sized type]: glossary.zst
[zero-sized types]: glossary.zst
[zero-sized structs]: glossary.zst
Copy link
Copy Markdown
Contributor

@traviscross traviscross Apr 29, 2026

Choose a reason for hiding this comment

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

"zero-sized structs" would sort before "zero-sized type".

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-glossary Area: glossary S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants