about summary refs log tree commit diff
path: root/src/libcore/mem.rs
AgeCommit message (Collapse)AuthorLines
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
2018-05-09Rollup merge of #50148 - japaric:const-manuallydrop, r=oli-obkkennytm-1/+2
turn `ManuallyDrop::new` into a constant function
2018-05-07Rename PinMut::borrow to PinMut::reborrow and make it a methodRalf Jung-3/+6
2018-05-07PinMut::get_mut can also preserve the lifetimeRalf Jung-1/+1
2018-05-07Change PinMut::map to be able to preserve the original reference's lifetimeRalf Jung-1/+1
Suggested by @dylanede at <https://github.com/rust-lang/rust/issues/49150#issuecomment-381071442>.
2018-05-07Rename Pin to PinMutRalf Jung-24/+24
As discussed at [1] §3 and [2] and [3], a formal look at pinning requires considering a distinguished "shared pinned" mode/typestate. Given that, it seems desirable to at least eventually actually expose that typestate as a reference type. This renames Pin to PinMut, freeing the name Pin in case we want to use it for a shared pinned reference later on. [1] https://www.ralfj.de/blog/2018/04/10/safe-intrusive-collections-with-pinning.html [2] https://github.com/rust-lang/rfcs/pull/2349#issuecomment-379250361 [3] https://github.com/rust-lang/rust/issues/49150#issuecomment-380488275
2018-05-07make the const constructor unstableJorge Aparicio-0/+1
2018-04-21turn `ManuallyDrop::new` into a constant functionJorge Aparicio-1/+1
2018-04-16Stabilize core::hint::unreachable_unchecked.kennytm-12/+0
Closes #43751.
2018-04-03impl Unpin for PinWim Looman-0/+3
2018-03-18Update tracking issue.boats-14/+14
2018-03-15Pin and PinBox are fundamental.boats-0/+1
2018-03-14Pin and Unpin in libcore.boats-2/+109
2018-02-02Rollup merge of #46156 - SimonSapin:patch-14, r=withoutboatskennytm-0/+1
Document the size of bool
2017-12-27Correct a few stability attributesOliver Middleton-7/+7
2017-11-26Stabilize const-calling existing const-fns in stdSimon Sapin-2/+0
Fixes #46038
2017-11-21Document the size of boolSimon Sapin-0/+1
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-2/+2
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-10-13Clarify how needs_drop is conservativeAlexis Beingessner-3/+5
2017-10-08core: Ensure std::mem::Discriminant is Send + SyncUlrik Sverdrup-1/+1
`PhantomData<*const T>` has the implication of Send / Syncness following the *const T type, but the discriminant should always be Send and Sync. Use `PhantomData<fn() -> T>` which has the same variance in T, but is Send + Sync
2017-10-01Auto merge of #44897 - Havvy:doc-size_of, r=steveklabnikbors-0/+78
Docs for size_of::<#[repr(C)]> items. Most of this info comes from camlorn's blog post on optimizing struct layout and the Rustonomicon. I don't really like my wording in the first paragraph. I also cannot find a definition of what `#[repr(C)]` does for enums that have variants with fields. They're allowed, unlike `#[repr(C)] enum`s with no variants.
2017-09-28Remove link duplication.Havvy-3/+3
2017-09-27Backticks.Havvy-1/+1
2017-09-27Docs for size_of::<#[repr(C)]> items.Havvy-0/+78
Most of this info comes from camlorn's blog post on optimizing struct layout and the Rustonomicon.
2017-09-24Backport libs stabilizations to 1.21 betaDavid Tolnay-1/+1
This includes the following stabilizations: - tcpstream_connect_timeout https://github.com/rust-lang/rust/pull/44563 - iterator_for_each https://github.com/rust-lang/rust/pull/44567 - ord_max_min https://github.com/rust-lang/rust/pull/44593 - compiler_fences https://github.com/rust-lang/rust/pull/44595 - needs_drop https://github.com/rust-lang/rust/pull/44639 - vec_splice https://github.com/rust-lang/rust/pull/44640
2017-09-23Rollup merge of #44648 - Havvy:doc-size_of, r=dtolnayCorey Farwell-2/+46
Expand size_of docs This PR does 3 things. 1. Adds a description of what pointer size means to the primitive pages for usize and isize. 2. Says the general size of things is not stable from compiler to compiler. 3. Adds a table of sizes of things that we do guarantee. As this is the first table in the libstd docs, I've included a picture of how that looks. ![](https://i.imgur.com/YZ6IChH.png?1)
2017-09-20Document stable size_of primitives and pointer size guaranteesHavvy-2/+46
2017-09-16stabilized needs_drop (fixes #41890)Michal Budzynski-2/+1
2017-09-16Auto merge of #43017 - durka:stabilize-const-invocation, r=eddybbors-0/+2
Individualize feature gates for const fn invocation This PR changes the meaning of `#![feature(const_fn)]` so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward. This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review. - `std::cell` - `Cell::new` - `RefCell::new` - `UnsafeCell::new` - `std::mem` - `size_of` - `align_of` - `std::ptr` - `null` - `null_mut` - `std::sync` - `atomic` - `Atomic{Bool,Ptr,Isize,Usize}::new` - `once` - `Once::new` - primitives - `{integer}::min_value` - `{integer}::max_value` Some other functions are const but they are also unstable or hidden, e.g. `Unique::new` so they don't have to be considered at this time. After this stabilization, the following `*_INIT` constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR. - `std::sync` - `atomic` - `ATOMIC_{BOOL,ISIZE,USIZE}_INIT` - `once` - `ONCE_INIT`
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-0/+2
2017-09-13update "since" for discriminant_valueAlex Burka-8/+8
It's going to be backported to beta.
2017-09-04Additional traits for std::mem::ManuallyDropLance Roy-4/+61
Add pass-through implementations for all of the derivable traits. These cannot be derived since ManuallyDrop is a union.
2017-09-04Derive std::mem::ManuallyDrop from Clone and Copy.Lance Roy-0/+14
Although types that don't implement Drop can't be Copyable, this can still be useful when ManuallyDrop is used inside a generic type. This doesn't derive from Copy as that would require T: Copy + Clone, instead it provides an impl of Clone for T: Clone.
2017-09-02stabilize mem::discriminant (closes #24263)Alex Burka-9/+8
2017-08-31Update bootstrap compilerAlex Crichton-43/+0
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-24Fix inconsistent doc headingslukaramu-1/+1
This fixes headings reading "Unsafety" and "Example", they should be "Safety" and "Examples" according to RFC 1574.
2017-08-11Add `#[inline]` to `mem::unreachable`Tobias Bucher-0/+1
2017-08-09`mem::unreachable`: Add tracking issueTobias Bucher-1/+1
2017-08-09Put `intrinsics::unreachable` on a possible path to stabilizationTobias Bucher-0/+11
Mark it with the `unreachable` feature and put it into the `mem` module. This is a pretty straight-forward API that can already be simulated in stable Rust by using `transmute` to create an uninhabited enum that can be matched.
2017-07-25std: Stabilize `manually_drop` featureAlex Crichton-10/+7
Stabilizes * `core::mem::ManuallyDrop` * `std::mem::ManuallyDrop` * `ManuallyDrop::new` * `ManuallyDrop::into_inner` * `ManuallyDrop::drop` * `Deref for ManuallyDrop` * `DerefMut for ManuallyDrop` Closes #40673
2017-07-19Implement const fn {size,align}_of.Eduard-Mihai Burtescu-0/+43
2017-06-28Auto merge of #42819 - scottmcm:swap-nonoverlapping, r=sfacklerbors-53/+1
Reuse the mem::swap optimizations to speed up slice::rotate This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster. Exposes the swapping logic from PR https://github.com/rust-lang/rust/pull/40454 as `pub unsafe fn ptr::swap_nonoverlapping` under library feature `swap_nonoverlapping` https://github.com/rust-lang/rust/issues/42818. (The new method seemed plausible, and was the simplest way to share the logic. I'm not attached to it, though, so let me know if a different way would be better.)
2017-06-23Removed as many "```ignore" as possible.kennytm-4/+11
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-21Reuse the mem::swap optimizations to speed up slice::rotateScott McMurray-53/+1
Exposes the swapping logic from PR 40454 as `pub unsafe fn ptr::swap_nonoverlapping` under feature swap_nonoverlapping This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster.
2017-06-19Disable repr(simd) in mem::swap on RedoxJeremy Soller-2/+2
2017-06-11Auto merge of #40454 - djzin:fast-swap, r=sfacklerbors-13/+54
speed up mem::swap I would have thought that the mem::swap code didn't need an intermediate variable precisely because the pointers are guaranteed never to alias. And.. it doesn't! It seems that llvm will also auto-vectorize this case for large structs, but alas it doesn't seem to have all the aliasing info it needs and so will add redundant checks (and even not bother with autovectorizing for small types). Looks like a lot of performance could still be gained here, so this might be a good test case for future optimizer improvements. Here are the current benchmarks for the simd version of mem::swap; the timings are in cycles (code below) measured with 10 iterations. The timings for sizes > 32 which are not a multiple of 8 tend to be ever so slightly faster in the old code, but not always. For large struct sizes (> 1024) the new code shows a marked improvement. \* = latest commit † = subtracted from other measurements | arr_length | noop<sup>†</sup> | rust_stdlib | simd_u64x4\* | simd_u64x8 |------------------|------------|-------------------|-------------------|------------------- 8|80|90|90|90 16|72|177|177|177 24|32|76|76|76 32|68|188|112|188 40|32|80|60|80 48|32|84|56|84 56|32|108|72|108 64|32|108|72|76 72|80|350|220|230 80|80|350|220|230 88|80|420|270|270 96|80|420|270|270 104|80|500|320|320 112|80|490|320|320 120|72|528|342|342 128|48|360|234|234 136|72|987|387|387 144|80|1070|420|420 152|64|856|376|376 160|68|804|400|400 168|80|1060|520|520 176|80|1070|520|520 184|32|464|228|228 192|32|504|228|228 200|32|440|248|248 208|72|987|573|573 216|80|1464|220|220 224|48|852|450|450 232|72|1182|666|666 240|32|428|288|288 248|32|428|308|308 256|80|860|770|770 264|80|1130|820|820 272|80|1340|820|820 280|80|1220|870|870 288|72|1227|804|804 296|72|1356|849|849