Make Vec from a pointer that is valid for mutation #614
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.
slice::as_ptr
documents that the returned pointer or any pointer derived from it may not be used for mutation. It is therefore unsound to construct aVec
using this pointer, the docs adviseas_raw_ptr
instead: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_ptrI also specified the type in the cast, because
as _
can produce very surprising behavior in unsafe code due to the reference and pointer coercions.This issue can be detected with
MIRIFLAGS="-Zmiri-tag-raw-pointers" cargo miri test
This change would be rendered unnecessary by #603 but I can't tell what state that is in, the CI logs seem to have expired.