about summary refs log tree commit diff
path: root/src/libcore/mem
AgeCommit message (Collapse)AuthorLines
2019-08-15Auto merge of #63575 - Centril:rollup-anlv9g5, r=Centrilbors-6/+6
Rollup of 11 pull requests Successful merges: - #62984 (Add lint for excess trailing semicolons) - #63075 (Miri: Check that a ptr is aligned and inbounds already when evaluating `*`) - #63490 (libsyntax: cleanup and refactor `pat.rs`) - #63507 (When needing type annotations in local bindings, account for impl Trait and closures) - #63509 (Point at the right enclosing scope when using `await` in non-async fn) - #63528 (syntax: Remove `DummyResult::expr_only`) - #63537 (expand: Unimplement `MutVisitor` on `MacroExpander`) - #63542 (Add NodeId for Arm, Field and FieldPat) - #63543 (Merge Variant and Variant_) - #63560 (move test that shouldn't be in test/run-pass/) - #63570 (Adjust tracking issues for `MaybeUninit<T>` gates) Failed merges: r? @ghost
2019-08-14Adjust tracking issues for `MaybeUninit<T>` gatesMazdak Farrokhzad-6/+6
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-3/+3
2019-08-11Rollup merge of #63346 - RalfJung:zeroed-lint, r=eddybMark Rousskov-1/+5
Lint on some incorrect uses of mem::zeroed / mem::uninitialized Cc https://github.com/rust-lang/rust/issues/62825 and https://internals.rust-lang.org/t/make-mem-uninitialized-and-mem-zeroed-panic-for-some-types-where-0-is-a-niche/10605 This does not yet handle `NonNull`/`NonZero*`, but it is a start. I also improved some doc issues I hit on the way, and added a useful helper to `TyS`. EDIT: I added the relnotes label mostly as a proposal -- I think this is worth mentioning, but leave the decision up to the release team.
2019-08-11allow the lint if a few UB-demonstrating doc testsRalf Jung-1/+5
2019-08-11Auto merge of #63343 - ishitatsuyuki:revert-62150, r=RalfJungbors-2/+8
Back out #62150 Ref: #62825 cc @RalfJung
2019-08-10Revert "Rollup merge of #62150 - alex:mem-uninit-refactor, r=RalfJung"Tatsuyuki Ishi-2/+8
This reverts commit 1d45156866b54c3fc36edfdfcdd8149ad9cb5711, reversing changes made to 0f92eb8a4a7d8715381f5b5d748d22315f6ff9c7.
2019-08-07Rollup merge of #63034 - tmandry:reduce-generator-size-regressions, r=cramertjMazdak Farrokhzad-0/+2
Fix generator size regressions due to optimization I tested the generator optimizations in #60187 and #61922 on the Fuchsia build, and noticed that some small generators (about 8% of the async fns in our build) increased in size slightly. This is because in #60187 we split the fields into two groups, a "prefix" non-overlap region and an overlap region, and lay them out separately. This can introduce unnecessary padding bytes between the two groups. In every single case in the Fuchsia build, it was due to there being only a single variant being used in the overlap region. This means that we aren't doing any overlapping, period. So it's better to combine the two regions into one and lay out all the fields at once, which is what this change does. r? @cramertj cc @eddyb @Zoxc
2019-08-06clarifyRalf Jung-2/+2
2019-08-06be clear that 1-init Vec being valid (but not safe) is not a stable guaranteeRalf Jung-2/+4
2019-08-05assume_init: warn about valid != safeRalf Jung-0/+7
2019-08-03Rollup merge of #63215 - gnzlbg:patch-6, r=CentrilMazdak Farrokhzad-3/+6
Clarify semantics of mem::zeroed Clarifies the semantics of `mem::zeroed`. r? @Centril cc @RalfJung
2019-08-02Consistency.gnzlbg-1/+1
2019-08-02Remove trailing whitespacegnzlbg-1/+1
I had one job...
2019-08-02Clarify semantics of mem::zeroedgnzlbg-3/+6
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