Add missing safety requirement - #25269
Open
yilin0518 wants to merge 1 commit into
Open
Conversation
hymm
reviewed
Aug 2, 2026
| /// # Safety | ||
| /// - `dst` must be valid for writes. | ||
| /// - If the `A` type parameter is [`Aligned`] then `dst` must be [properly aligned] for `T`. | ||
| /// - The `size_of::<T>()` byte regions beginning at `dst` and at this pointer's |
Contributor
There was a problem hiding this comment.
Since this is only for a single element, the requirement could be reduced to self and dst not being the same.
Contributor
Author
There was a problem hiding this comment.
I have updated the wording of this requirement. Thank you for your suggestion!
| // - As `A` is `Aligned`, the caller is required to ensure that `dst` is aligned and `src` must | ||
| // be aligned by the type's invariants. | ||
| // - The caller is required to ensure that the memory region covered by `src` | ||
| // and `dst`, fitting up to `count` elements do not overlap. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
MovingPtr::write_to.ptr::copy_nonoverlapping, so callers must ensure that the source and destination memory regions do not overlap.Solution
MovingPtr::write_tosafety documentation to require non-overlapping source and destination regions.copy_nonoverlappingcall.Testing
cargo test -p bevy_ptr