Repository navigation
Guarantee that the never type ! is zero-sized and 1-aligned. - #2309
Conversation
This comment has been minimized.
This comment has been minimized.
|
@rustbot label I-lang-nominated cc @traviscross |
|
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. |
| r[type.never.coercion] | ||
| Expressions of type `!` can be coerced into any type. | ||
|
|
||
|
|
There was a problem hiding this comment.
no need for two blank lines here, one should be enough
There was a problem hiding this comment.
Latest push removes the extra blank line.
| assert_eq!(0, size_of::<E4>()); | ||
| assert_eq!(0, size_of::<E5>()); | ||
| assert_eq!(0, size_of::<E6>()); | ||
| assert_eq!(0, size_of::<E7>()); |
There was a problem hiding this comment.
there should also be an example in the test block here
| assert_eq!(0, size_of::<!>()); |
There was a problem hiding this comment.
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 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. |
|
@rfcbot reviewed |
4 similar comments
|
@rfcbot reviewed |
|
@rfcbot reviewed |
|
@rfcbot reviewed |
|
@rfcbot reviewed |
|
@digama0 @joshtriplett @scottmcm @nikomatsakis friendly checkbox reminder -- I think this should be fairly uncontroversial :) |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
Agreed, Ralf -- I see no reason anyone could possibly want anything else 🙃 |
There was a problem hiding this comment.
This has tests for size. Should it also have a test for alignment? Or is that covered elsewhere?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
I opened rust-lang/rust#163570 to add tests for ! (and bool)'s size/align to coretests.
There was a problem hiding this comment.
Size-1 types cannot have any alignment other than 1 anyway.
There was a problem hiding this comment.
You can add this to the glossary n-zst entry as an example of a 1-ZST, https://github.com/rust-lang/reference/blob/a286e1ecb8ce193d50056e4bb042eea9b23876ef/src/glossary.md#n-aligned-zero-sized-type-n-zst
|
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. |
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.
c0374f2 to
956d1bd
Compare
|
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. |
|
Thanks @zachs18. |
Needs T-lang FCP.