Skip to content

Conversation

@RalfJung
Copy link
Member

See #138351 for context.

We made ptr::read and ptr::write not UB on ZST null pointers. This does the same with ptr::replace. Since we're just adding a branch on a constant, this should come at no runtime cost.

@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 Nov 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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

@RalfJung RalfJung force-pushed the replace-zst-null-ptr branch from bb81fb2 to 43aa6a7 Compare November 21, 2025 12:07
@RalfJung
Copy link
Member Author

RalfJung commented Dec 7, 2025

@rust-lang/libs any thoughts on this?
Independent of what exactly we decide in #138351, this seems like a basically free way to make replace have less UB and be more consistent with read and write.

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.

4 participants