Skip to content

Clarify as_uninit_mut may point to uninitialized memory#158804

Open
yilin0518 wants to merge 1 commit into
rust-lang:mainfrom
yilin0518:fix_as_uninit_mut
Open

Clarify as_uninit_mut may point to uninitialized memory#158804
yilin0518 wants to merge 1 commit into
rust-lang:mainfrom
yilin0518:fix_as_uninit_mut

Conversation

@yilin0518

@yilin0518 yilin0518 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Tracking issue: #75402

This PR clarifies the safety documentation for *mut T::as_uninit_mut.

Unlike as_mut, this method creates a reference to MaybeUninit<T>, so the source pointer may point to uninitialized memory. The pointer still must either be null or satisfy the pointer-to-reference conversion requirements.

After adding the supplementary information, the safety documentation of *mut T::as_uninit_mut is consistent with *mut T::as_uninit_ref, *const T::as_uninit_ref and std::ptr::NonNull::as_uninit_mut.

This is a documentation-only change.

Tests were not added because this only updates API docs.

@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 Jul 5, 2026
@rustbot

rustbot commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

r? @LawnGnome

rustbot has assigned @LawnGnome.
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: libs
  • libs expanded to 12 candidates
  • Random selection from 6 candidates

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants