Skip to content

Guarantee that the never type ! is zero-sized and 1-aligned. - #2309

Merged
traviscross merged 5 commits into
rust-lang:masterfrom
zachs18:never-1zst
Oct 11, 2026
Merged

traviscross merged 5 commits into
rust-lang:masterfrom
zachs18:never-1zst

Conversation

@zachs18

@zachs18 zachs18 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Needs T-lang FCP.

@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Aug 11, 2026
@zachs18
zachs18 marked this pull request as ready for review August 25, 2026 20:25
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 25, 2026
@zachs18

zachs18 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot label I-lang-nominated

cc @traviscross

@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Error: Label I-lang-nominated can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

@traviscross traviscross added I-lang-nominated Nominated for discussion during a lang team meeting. needs-fcp I-lang-radar Items that are on lang's radar and will need eventual work or consideration. P-lang-drag-1 Lang team prioritization drag level 1. labels Aug 25, 2026
Comment thread src/types/never.md Outdated
r[type.never.coercion]
Expressions of type `!` can be coerced into any type.


@DanielEScherzer DanielEScherzer Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need for two blank lines here, one should be enough

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.

Latest push removes the extra blank line.

Comment thread src/glossary.md
assert_eq!(0, size_of::<E4>());
assert_eq!(0, size_of::<E5>());
assert_eq!(0, size_of::<E6>());
assert_eq!(0, size_of::<E7>());

@DanielEScherzer DanielEScherzer Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there should also be an example in the test block here

Suggested change
assert_eq!(0, size_of::<!>());

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.

Latest push adds this example at the top of the list just after ()'s line, so they're still in the same order as the list in the prose.

@traviscross traviscross added T-lang Relevant to the language team. T-opsem Team: opsem labels Sep 1, 2026
@traviscross

Copy link
Copy Markdown
Contributor

Thanks @zachs18.

@rfcbot fcp merge lang,opsem

@rust-rfcbot

rust-rfcbot commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@joshlf

joshlf commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@rfcbot reviewed

4 similar comments
@saethlin

saethlin commented Sep 1, 2026

Copy link
Copy Markdown
Member

@rfcbot reviewed

@CAD97

CAD97 commented Sep 2, 2026

Copy link
Copy Markdown

@rfcbot reviewed

@RalfJung

RalfJung commented Sep 2, 2026

Copy link
Copy Markdown
Member

@rfcbot reviewed

@tmandry

tmandry commented Sep 2, 2026

Copy link
Copy Markdown
Member

@rfcbot reviewed

@RalfJung

Copy link
Copy Markdown
Member

@digama0 @joshtriplett @scottmcm @nikomatsakis friendly checkbox reminder -- I think this should be fairly uncontroversial :)

@rust-rfcbot

Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@tmandry tmandry removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. labels Sep 30, 2026
@scottmcm

Copy link
Copy Markdown
Member

Agreed, Ralf -- I see no reason anyone could possibly want anything else 🙃
@rfcbot reviewed

Comment thread src/glossary.md

@tgross35 tgross35 Sep 30, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This has tests for size. Should it also have a test for alignment? Or is that covered elsewhere?

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.

We probably should have tests for alignment, but we don't have tests for other types' alignments in the reference (including bool which is also guaranteed to have an alignment of 1 (AFAICT we don't have tests for bool's size or alignment in the reference or rust-lang/rust)), so I don't think we need to add it in this PR (especially not the "Zero-sized type" section, which is specifically about size).

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.

I opened rust-lang/rust#163570 to add tests for ! (and bool)'s size/align to coretests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Size-1 types cannot have any alignment other than 1 anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

zachs18 and others added 5 commits October 10, 2026 23:56
We'd referred to "the never type `!`".  Mostly we should say either
"the never type" or "`!`"; using parentheses sparingly, as in "the
never type (`!`)", is also OK.  Let's fix this and a related case.
Since we're guaranteeing the alignment of the never type, let's add it
as an example of a 1-ZST in the glossary.
It might be a good idea to link to the pages for the types listed in
this table, but we don't do it for the others, so let's not do it for
the never type.
@rustbot

rustbot commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

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.

@traviscross

Copy link
Copy Markdown
Contributor

Thanks @zachs18.

@traviscross
traviscross enabled auto-merge October 11, 2026 09:02
@traviscross
traviscross added this pull request to the merge queue Oct 11, 2026
Merged via the queue into rust-lang:master with commit 5baa209 Oct 11, 2026
8 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge finished-final-comment-period I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. T-lang Relevant to the language team. T-opsem Team: opsem to-announce

Projects

None yet

Development

Successfully merging this pull request may close these issues.