summary refs log tree commit diff
path: root/src/libcore/mem.rs
AgeCommit message (Collapse)AuthorLines
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
2017-06-09hack around bug in emscriptenDjzin-1/+3
2017-05-31Rollup merge of #42252 - stjepang:clarify-alignof-docs, r=nikomatsakisMark Simulacrum-4/+4
Clarify the docs for align_of and its variants It's okay to have unaligned raw pointers and then use `ptr::write_unaligned` and `ptr::read_unaligned`. However, using unaligned `&T` and `&mut T` would be undefined behavior. The current documentation seems to indicate that everything has to be aligned, but in reality only references do. This PR changes the text of docs accordingly. r? @sfackler
2017-05-30Add 'the'Stjepan Glavina-4/+4
2017-05-28restore old behaviourDjzin-18/+1
2017-05-28restore old behaviour for sizes < 128Djzin-41/+34
2017-05-27better respect alignment for copying tailDjzin-25/+37
2017-05-27Merge remote-tracking branch 'upstream/master' into fast-swapDjzin-8/+178
2017-05-27copy tail bytes better for aligned typesDjzin-0/+21
2017-05-27Clarify the docs for align_of and its variantsStjepan Glavina-4/+4
2017-05-20expose needs_drop under mem::Alexis Beingessner-0/+52
2017-05-07fix nitDjzin-1/+1
2017-05-07improve wordingDjzin-2/+1
2017-05-07optimize out stack alignment for sizes < 32Djzin-5/+12
2017-04-29process:exit -> process::exit in mem::forget docsNathan Moos-1/+1
The documentation in mem::forget says "...or call `process:exit`..." instead of `process::exit`. r? @steveklabnik
2017-04-24change wordingDjzin-1/+1
2017-04-09into_inner to associated functionSimonas Kazlauskas-2/+19
2017-04-09 Replace the `forget` intrinsic with ManuallyDropSimonas Kazlauskas-1/+6
less intrinsics = better life
2017-04-09Implement Manually DropSimonas Kazlauskas-0/+96
2017-03-20Fix up various linkssteveklabnik-5/+5
The unstable book, libstd, libcore, and liballoc all needed some adjustment.
2017-03-15use simd blocksDjzin-10/+20
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-1/+1
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13add SWAP_BLOCK_SIZE constantDjzin-7/+9
2017-03-12fix typoDjzin-1/+1
2017-03-12a new approach; ditch xor cuteness and maximize cache localityDjzin-6/+18