Uh oh!
There was an error while loading. Please reload this page.
improve Vec example soundness in mem::transmute docs - #64436
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
RalfJung
commented
Sep 16, 2019
Nice! Yes However, the code is still somewhat confusing, with its three examples in one doctest and the {let v = v_orig.clone();// Here comes the "way" do do stuff with `v`.}That would make it more clear that the clone is part of the "environment" here, not part of what is really going on. However, we can also land this PR without that change as it is a definite improvement. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
| /// let v_clone: &mut Vec<_> = &mut *std::mem::ManuallyDrop::new(v_clone); | |
| /// let v_clone = std::mem::ManuallyDrop::new(v_clone); |
This should work due to the Deref, right? And I think it is more readable.
llogiq
commented
Sep 17, 2019
@RalfJung thanks for the review! |
RalfJung
commented
Sep 17, 2019
LGTM, thanks! @bors r+ rollup |
bors
commented
Sep 17, 2019
📌 Commit 14bb7550cd65a90f38ae3f17c2e46a7bb17b47aa has been approved by |
rust-highfive
commented
Sep 17, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
RalfJung
commented
Sep 17, 2019
@bors r- delegate+ |
bors
commented
Sep 17, 2019
✌️ @llogiq can now approve this pull request |
llogiq
commented
Sep 17, 2019
@bors r=RalfJung |
bors
commented
Sep 17, 2019
📌 Commit ab6e108 has been approved by |
improve Vec example soundness in mem::transmute docs The previous version of the `Vec` example had a case of questionable soundness, because at one point `v_orig` was aliased. r? @RalfJung
improve Vec example soundness in mem::transmute docs The previous version of the `Vec` example had a case of questionable soundness, because at one point `v_orig` was aliased. r? @RalfJung
Rollup of 10 pull requests Successful merges: - #61626 (Get rid of special const intrinsic query in favour of `const_eval`) - #64283 (Updated RELEASES.md for 1.38.0) - #64394 (Shrink `SubregionOrigin`.) - #64429 (Fix failure note `to_str` implementation) - #64436 (improve Vec example soundness in mem::transmute docs) - #64502 (avoid duplicate issues for Miri build failures) - #64505 (Fix inconsistent link formatting) - #64529 (Add an example to Pin::as_mut) - #64541 (document Miri error categories) - #64544 (build-manifest: re-add some comments) Failed merges: r? @ghost
The previous version of the
Vecexample had a case of questionable soundness, because at one pointv_origwas aliased.r? @RalfJung