about summary refs log tree commit diff
path: root/src/libcore/mem
AgeCommit message (Collapse)AuthorLines
2019-08-02Fix typos in doc comments.Bruce Mitchener-1/+1
2019-07-29Wrap promoted generator fields in MaybeUninitTyler Mandry-0/+2
This prevents uninhabited fields from "infecting" the abi and largest_niche of the generator layout. This fixes a latent bug, where an uninhabited field could be promoted to the generator prefix and cause the entire generator to become uninhabited.
2019-07-28Rollup merge of #62360 - Aaron1011:patch-2, r=RalfJungMazdak Farrokhzad-0/+2
Document that ManuallyDrop::drop should not called more than once Double dropping is unsound (e.g. https://github.com/rust-lang/rust/issues/60977). This commit documents the fact that `ManuallyDrop::drop` should not be called multiple times on the same instance, as it might not be immediately obvious that this counts as a use of uninitialized data.
2019-07-27Update wordingAaron Hill-1/+2
2019-07-24Fix typo in mem::uninitialized docMika Lehtinen-1/+1
2019-07-21tidy is being sillyRalf Jung-5/+2
2019-07-21use a const to hack around promotion limitationsRalf Jung-1/+8
2019-07-19use const array repeat expressions for uninit_arrayRalf Jung-0/+1
2019-07-15Rollup merge of #62634 - llogiq:uninit-array-docs, r=RalfJungMark Rousskov-5/+7
Less unsafe in the array example of MaybeUninit docs I believe this is an acceptable way to initialize elements of `[MaybeUninit<T>; _]` arrays. Miri agrees. Conceptually, we are working at the array level, above the `MaybeUninit`, and as we are replacing it wholesale, this should pose no problem to soundness. And the code is easier to read. r? @RalfJung
2019-07-14Less unsafe in the array example of MaybeUninit docsAndre Bogus-5/+7
2019-07-11move mem::uninitialized deprecation back by 1 release, to 1.39Ralf Jung-1/+1
2019-07-05Rollup merge of #62150 - alex:mem-uninit-refactor, r=RalfJungMazdak Farrokhzad-4/+2
Implement mem::{zeroed,uninitialized} in terms of MaybeUninit. Refs #62061 r? @oli-obk
2019-07-04Switch master to 1.38Mark Rousskov-1/+1
2019-07-04Implement mem::{zeroed,uninitialized} in terms of MaybeUninit.Alex Gaynor-4/+2
Refs #62061
2019-07-03Improve formatting of 'ManuallyDrop'Aaron Hill-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-07-03Document that ManuallyDrop::drop should not called more than onceAaron Hill-1/+2
Double dropping is unsound (e.g. https://github.com/rust-lang/rust/issues/60977). This commit documents the fact that `ManuallyDrop::drop` should not be called multiple times on the same instance, as it might not be immediately obvious that this counts as a use of uninitialized data.
2019-06-30Update mem::replace example to not be identical to mem::takeChris Gregory-8/+20
This also adds assertions that the operations work as expected.
2019-06-29Rollup merge of #61199 - ollie27:rustdoc_cfg_test, r=QuietMisdreavusMazdak Farrokhzad-1/+4
Revert "Set test flag when rustdoc is running with --test option" Reverts https://github.com/rust-lang/rust/pull/59940. It caused doctests in this repository to no longer be tested including all of the core crate.
2019-06-18Make MaybeUninit #[repr(transparent)]Michael Bradshaw-1/+15
Tracking issue: #60405
2019-06-09Fix more tests after revert of rustdoc cfg(test) featureOliver Middleton-1/+4
2019-06-07Auto merge of #61130 - jonhoo:mem-take, r=SimonSapinbors-0/+55
Add std::mem::take as suggested in #61129 This PR implements #61129 by adding `std::mem::take`. The added function is equivalent to: ```rust std::mem::replace(dest, Default::default()) ``` This particular pattern is fairly common, especially when implementing `Future::poll`, where you often need to yield an owned value in `Async::Ready`. This change allows you to write ```rust return Async::Ready(std::mem::take(self.result)); ``` instead of ```rust return Async::Ready(std::mem::replace(self.result, Vec::new())); ``` EDIT: Changed name from `take` to `swap_default`. EDIT: Changed name back to `take`.
2019-06-05Escape needs_drop in the needs_drop documentationChris Gregory-1/+1
2019-06-05Escape HashMap with backticks in needs_drop docsChris Gregory-1/+1
2019-05-29Add std::mem::take as suggested in #61129Jon Gjengset-0/+55
The name `swap_default` was suggested but rejected. @SimonSapin observed that this operation isn't really a `swap` in the same sense as `mem::swap`; it is a `replace`. Since `replace_default` is a bit misleading, the "correct" name would be `replace_with_default`, which is quite verbose. @czipperz observed that we have precedence for using `take` to refer to methods that replace with `Default` in `Cell::take` and `Option::take`, so this reverts commit 99c00591c29b472c8a87c4a9342d0e0c508647a3 to return to the original `take` method name. The name `replace_with_default` was suggested, but was deemed too verbose, especially given that we use `take` for methods that replace with `Default` elsewhere.
2019-05-29split libcore::mem into multiple filesRalf Jung-0/+1417