Skip to content

core: clarify MaybeUninit::assume_init UB for uninitialized integers#153253

Closed
laddery-a wants to merge 2 commits intorust-lang:mainfrom
laddery-a:claw/maybeuninit-docs-uninit-pod
Closed

core: clarify MaybeUninit::assume_init UB for uninitialized integers#153253
laddery-a wants to merge 2 commits intorust-lang:mainfrom
laddery-a:claw/maybeuninit-docs-uninit-pod

Conversation

@laddery-a
Copy link

@laddery-a laddery-a commented Mar 1, 2026

Fixes #150689.

This clarifies in the MaybeUninit::assume_init safety docs that calling assume_init on uninitialized memory is immediate UB even when T is an integer / POD type, and adds a small incorrect-usage example using u8.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 1, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 1, 2026

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet, scottmcm

@scottmcm
Copy link
Member

scottmcm commented Mar 1, 2026

When you're done changing things and have squashed the commits and updated the OP comment, use @rustbot ready to put this back in the queue.

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 1, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 1, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 1, 2026
@asder8215
Copy link
Contributor

Isn't this being worked on in #153030?

@RalfJung
Copy link
Member

RalfJung commented Mar 2, 2026

Yeah this is a duplicate.

@laddery-a thanks for helping improve our docs! However, before you work on fixing an opened issue, please check that the issue isn't already claimed by someone. #150689 has an assignee so it is clearly claimed. I will therefore close this PR in favor of #153030. Your feedback is welcome on that PR!

@RalfJung RalfJung closed this Mar 2, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 2, 2026
@laddery-a
Copy link
Author

laddery-a commented Mar 3, 2026

Thanks for the quick review. Sorry I missed that this was already being handled in #153030 (and that #150689 was already claimed).
I’ll follow up there with any feedback and won’t duplicate work. Feel free to delete this branch.

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

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs for MaybeUninit::assume_init should indicate that reading uninit POD isn't sound

5 participants