summary refs log tree commit diff
path: root/src/libcore/mem.rs
AgeCommit message (Collapse)AuthorLines
2018-12-02let FIXME refer to tracking issueRalf Jung-1/+1
2018-11-28put the MaybeUninit inside the UnsafeCellRalf Jung-3/+0
2018-11-27add comments explaining our uses of get_ref/get_mut for MaybeUninitRalf Jung-0/+6
2018-11-23use more inlining, and force some of itRalf Jung-4/+13
2018-11-22Rollup merge of #55485 - petertodd:2018-10-manuallydrop-deref, r=TimNNGuillaume Gomez-2/+2
Return &T / &mut T in ManuallyDrop Deref(Mut) impl Without this change the generated documentation looks like this: fn deref(&self) -> &<ManuallyDrop<T> as Deref>::Target Returning the actual type directly makes the generated docs more clear: fn deref(&self) -> &T Basically, compare how the impl for `Box<T>` and `ManuallyDrop<T>` looks in this screenshot: ![rust docs for ManuallyDrop as Deref](https://user-images.githubusercontent.com/7042/47673083-fc9dc280-db89-11e8-89b0-c6bde663feef.png)
2018-11-21update various stdlib docsSteve Klabnik-10/+5
2018-11-15Rollup merge of #55785 - stjepang:unsized-drop-forget, r=alexcrichtonPietro Albini-0/+13
Add mem::forget_unsized() for forgetting unsized values ~~Allows passing values of `T: ?Sized` types to `mem::drop` and `mem::forget`.~~ Adds `mem::forget_unsized()` that accepts `T: ?Sized`. I had to revert the PR that removed the `forget` intrinsic and replaced it with `ManuallyDrop`: https://github.com/rust-lang/rust/pull/40559 We can't use `ManuallyDrop::new()` here because it needs `T: Sized` and we don't have support for unsized return values yet (will we ever?). r? @eddyb
2018-11-13Auto merge of #55052 - newpavlov:patch-2, r=alexcrichtonbors-1/+1
Use read_unaligned instead of read in transmute_copy Closes: #55044 This change could result in performance regression on non-x86 platforms. (but it also can fix some of UB which lurks in existing programs) An alternative would be to update `transmute_copy` documentation with alignment requirements.
2018-11-12Auto merge of #55278 - Centril:constification-1, r=alexcrichtonbors-2/+1
Minor standard library constification This PR makes some bits of the standard library into `const fn`s. I've tried to be as aggressive as I possibly could in the constification. The list is rather small due to how restrictive `const fn` is at the moment. r? @oli-obk cc @rust-lang/libs Stable public APIs affected: + [x] `Cell::as_ptr` + [x] `UnsafeCell::get` + [x] `char::is_ascii` + [x] `iter::empty` + [x] `ManuallyDrop::{new, into_inner}` + [x] `RangeInclusive::{start, end}` + [x] `NonNull::as_ptr` + [x] `{[T], str}::as_ptr` + [x] `Duration::{as_secs, subsec_millis, subsec_micros, subsec_nanos}` + [x] `CStr::as_ptr` + [x] `Ipv4Addr::is_unspecified` + [x] `Ipv6Addr::new` + [x] `Ipv6Addr::octets` Unstable public APIs affected: + [x] `Duration::{as_millis, as_micros, as_nanos, as_float_secs}` + [x] `Wrapping::{count_ones, count_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, reverse_bits, from_be, from_le, to_be, to_le, leading_zeros, is_positive, is_negative, leading_zeros}` + [x] `core::convert::identity` -------------------------- ## Removed from list in first pass: Stable public APIs affected: + [ ] `BTree{Map, Set}::{len, is_empty}` + [ ] `VecDeque::is_empty` + [ ] `String::{is_empty, len}` + [ ] `FromUtf8Error::utf8_error` + [ ] `Vec<T>::{is_empty, len}` + [ ] `Layout::size` + [ ] `DecodeUtf16Error::unpaired_surrogate` + [ ] `core::fmt::{fill, width, precision, sign_plus, sign_minus, alternate, sign_aware_zero_pad}` + [ ] `panic::Location::{file, line, column}` + [ ] `{ChunksExact, RChunksExact}::remainder` + [ ] `Utf8Error::valid_up_to` + [ ] `VacantEntry::key` + [ ] `NulError::nul_position` + [ ] `IntoStringError::utf8_error` + [ ] `IntoInnerError::error` + [ ] `io::Chain::get_ref` + [ ] `io::Take::{limit, get_ref}` + [ ] `SocketAddrV6::{flowinfo, scope_id}` + [ ] `PrefixComponent::{kind, as_os_str}` + [ ] `Path::{ancestors, display}` + [ ] `WaitTimeoutResult::timed_out` + [ ] `Receiver::{iter, try_iter}` + [ ] `thread::JoinHandle::thread` + [ ] `SystemTimeError::duration` Unstable public APIs affected: + [ ] `core::fmt::Arguments::new_v1` + [ ] `core::fmt::Arguments::new_v1_formatted` + [ ] `Pin::{get_ref, into_ref}` + [ ] `Utf8Lossy::chunks` + [ ] `LocalWaker::as_waker` + [ ] `panic::PanicInfo::{internal_constructor, message, location}` + [ ] `panic::Location::{internal_constructor }` ## Removed from list in 2nd pass: Stable public APIs affected: + [ ] `LinkedList::{new, iter, is_empty, len}` + [ ] `mem::forget` + [ ] `Cursor::{new, get_ref, position}` + [ ] `io::{empty, repeat, sink}` + [ ] `PoisonError::new` + [ ] `thread::Builder::new` + [ ] `process::Stdio::{piped, inherit, null}` Unstable public APIs affected: + [ ] `io::Initializer::{zeroing, should_initialize}`
2018-11-12Update docsStjepan Glavina-16/+3
2018-11-12Add forget_unsized onlyStjepan Glavina-107/+15
2018-11-10Fix documentation typos.Bruce Mitchener-4/+4
2018-11-10revert some more constification.Mazdak Farrokhzad-1/+1
2018-11-10constify parts of libcore.Mazdak Farrokhzad-3/+2
2018-11-08Allow unsized types in mem::drop and mem::forgetStjepan Glavina-1/+119
2018-10-31Bump nightly to 1.32.0Alex Crichton-11/+2
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-29Return &T / &mut T in ManuallyDrop Deref(Mut) implPeter Todd-2/+2
Without this change the generated documentation looks like this: fn deref(&self) -> &<ManuallyDrop<T> as Deref>::Target Returning the actual type directly makes the generated docs more clear: fn deref(&self) -> &T
2018-10-28Rollup merge of #55421 - CAD97:patch-1, r=kennytmkennytm-0/+20
Add ManuallyDrop::take Tracking issue: #55422 Proposed in this form in https://internals.rust-lang.org/t/mini-rfc-manuallydrop-take/8679, see that thread for some history. A small convenience wrapper for `ManuallyDrop` that makes a pattern (taking ownership of the contained data in drop) more obvious.
2018-10-28Add ManuallyDrop::takeChristopher Durham-0/+20
https://internals.rust-lang.org/t/mini-rfc-manuallydrop-take/8679
2018-10-21Add MaybeUninit::newSimon Sapin-0/+9
Sometimes it *is* initialized!
2018-10-13Use read_unaligned instead of read in transmute_copyArtyom Pavlov-1/+1
Closes: #55044 This change could result in performance regression on non-x86 platforms. Alternative would be to update `transmute_copy` with alignment requirements.
2018-10-03Only promote calls to `#[rustc_promotable]` const fnsOliver Schneider-0/+2
2018-09-30Auto merge of #54596 - mjbshaw:drop, r=RalfJungbors-0/+10
Make core::mem::needs_drop a const fn This fixes #51929.
2018-09-27Bump to 1.31.0 and bootstrap from 1.30 betaJosh Stone-28/+0
2018-09-26Gate const core::mem::needs_drop behind const_needs_dropMichael Bradshaw-0/+1
2018-09-26Make core::mem::needs_drop a const fnMichael Bradshaw-0/+9
2018-09-22don't deprecate mem::{uninitialized,zeroed} just yetJorge Aparicio-2/+3
2018-09-22add MaybeUninit and deprecate mem::{uninitialized,zeroed}Jorge Aparicio-0/+95
2018-09-04Clarify `ManuallyDrop` docsTobias Bucher-2/+8
Mention that you can use `into_inner` to drop the contained value.
2018-08-31Implement the `min_const_fn` feature gateOliver Schneider-0/+28
2018-08-27Auto merge of #53227 - nivkner:pin_move, r=RalfJungbors-147/+2
move the Pin API into its own module for centralized documentation This implements the change proposed by @withoutboats in #49150, as suggested by @RalfJung in the review of #53104, along with the documentation that was originally in it, that was deemed more appropriate in module-level documentation. r? @RalfJung
2018-08-23Discourage overuse of mem::forgetKornel-39/+7
2018-08-23move PinMut into pin module and export through stdNiv Kaminer-147/+2
2018-08-09repr(transparent)Ralf Jung-0/+1
2018-08-06remove unnecessary CoerceUnsized implRalf Jung-3/+0
2018-08-03unsized ManuallyDropRalf Jung-3/+8
2018-08-01Switch to bootstrapping from 1.29 betaMark Rousskov-7/+0
2018-07-25Change ManuallyDrop from an union to a struct and make it a lang item.Eduard-Mihai Burtescu-92/+16
2018-07-21Don't use SIMD in mem::swap for types smaller than the block sizeScott McMurray-1/+1
LLVM isn't able to remove the alloca for the unaligned block in the SIMD tail in some cases, so doing this helps SRoA work in cases where it currently doesn't. Found in the `replace_with` RFC discussion.
2018-07-05Clarifying how the alignment of the struct worksVal Markovic-1/+4
The docs were not specifying how to compute the alignment of the struct, so I had to spend some time trying to figure out how that works. Found the answer [on this page](http://camlorn.net/posts/April%202017/rust-struct-field-reordering.html): > The total size of this struct is 5, but the most-aligned field is b with alignment 2, so we round up to 6 and give the struct an alignment of 2 bytes.
2018-07-02Implement `UnsafeFutureObj` for `&mut Future`Josef Reinhard Brandl-1/+3
2018-07-02Make `drop` method for `PinMut`'s `UnsafeFutureObj` impl emptyJosef Reinhard Brandl-3/+1
2018-07-02`UnsafeFutureObj` impl for `PinMut`Josef Reinhard Brandl-0/+17
2018-06-23`PinMut`: Add safe `get_mut` and rename unsafe fns to `get_mut_unchecked` ↵Josef Reinhard Brandl-4/+10
and `map_unchecked`
2018-06-08Document size_of for 128-bit integersbstrie-0/+2
We might want to consider separately documenting the alignment of primitives, rather than just their size, since 128-bit integers, unlike all other primitives, have an alignment that is not identical to their size (size_of is 16, align_of is 8)
2018-06-02Rollup merge of #51124 - frewsxcv:frewsxcv-replace, r=QuietMisdreavusMark Simulacrum-2/+3
Reword {ptr,mem}::replace docs. Fixes https://github.com/rust-lang/rust/issues/50657.
2018-06-01Reword {ptr,mem}::replace docs.Corey Farwell-2/+3
Fixes https://github.com/rust-lang/rust/issues/50657.
2018-05-30Add doc link from discriminant struct to function.Corey Farwell-1/+3
2018-05-22Add PinMut::setTaylor Cramer-0/+8
2018-05-22Make `Unpin` safe to implementTaylor Cramer-1/+1