about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2019-10-18Uninitialized boxes: add test for zero-size allocationsSimon Sapin-0/+20
2019-10-18BTreeSet symmetric_difference & union optimized, cleanedStein Somers-121/+144
2019-10-17example for padding any formatRalf Jung-2/+6
2019-10-17reorder fmt docs for more clarityRalf Jung-42/+61
2019-10-17more consistency and clarificationRalf Jung-13/+17
2019-10-17Rc: value -> allocationRalf Jung-44/+51
2019-10-16Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-9/+13
- Compatible with Emscripten 1.38.46-upstream or later upstream. - Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the old incorrect wasm32 C call ABI with the correct one, preserving the old one as wasm32_bindgen_compat for wasm-bindgen compatibility. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
2019-10-16Uninitialized boxes: check for zero-size allocation based on Layout::sizeSimon Sapin-4/+4
2019-10-14Rollup merge of #65332 - RalfJung:fmt, r=cramertjTyler Mandry-191/+175
std::fmt: reorder docs This moves the "Formatting Parameters" section up above right after the discussion of named and positional arguments. Then comes the "Syntax" section, summarizing the discussion of format string syntax. And only *then* we get to "Formatting Traits" -- that section has some *huge* code examples, so it really should not interrupt the discussion of the grammar. Also users are much more likely to come here to learn about the format string grammar than to come here to learn about the `Binary` trait.
2019-10-13Rollup merge of #65373 - kalabukdima:patch-1, r=jonas-schievinkMazdak Farrokhzad-2/+2
Fix typo in docs for `Rc` r? @czipperz
2019-10-13Rollup merge of #65214 - Amanieu:cfg_atomic, r=alexcrichtonMazdak Farrokhzad-1/+1
Split non-CAS atomic support off into target_has_atomic_load_store This PR implements my proposed changes in https://github.com/rust-lang/rust/issues/32976#issuecomment-518542029 by removing `target_has_atomic = "cas"` and splitting `target_has_atomic` into two separate `cfg`s: * `target_has_atomic = 8/16/32/64/128`: This indicates the largest width that the target can atomically CAS (which implies support for all atomic operations). * ` target_has_atomic_load_store = 8/16/32/64/128`: This indicates the largest width that the target can support loading or storing atomically (but may not support CAS). cc #32976 r? @alexcrichton
2019-10-13Fix typo in docs for `Rc`kalabukdima-2/+2
2019-10-13Rollup merge of #65069 - crgl:clone-from-vec-deque, r=blussMazdak Farrokhzad-2/+122
Implement Clone::clone_from for VecDeque See #28481. For simple data types with the target much longer than the source, this implementation can be significantly slower than the default (probably due to the use of truncate). However, it should be substantially faster when cloning from nested data structures with similar shapes or when cloning from VecDeques with similar lengths, hopefully more common use cases for clone_from.
2019-10-12remove confusing and redundant subsectionRalf Jung-17/+0
2019-10-12move Formatting Traits downRalf Jung-182/+182
2019-10-12std::fmt: move format string grammar to the bottomRalf Jung-24/+25
2019-10-11Auto merge of #64877 - lzutao:stabilize-repeat_generic_slice, r=SimonSapinbors-6/+1
Stabilize `slice::repeat` (feature `repeat_generic_slice`) Closes #48784 r? @SimonSapin
2019-10-10Override nth for VecDeque Iter and IterMutCharles Gleason-0/+20
2019-10-10Add tests for VecDeque clone_fromCharles Gleason-0/+23
2019-10-10Implement Clone::clone_from for VecDequeCharles Gleason-2/+79
2019-10-08Stabilize mem::take (mem_take)Jon Gjengset-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-08Split non-CAS atomic support off into target_has_atomic_load_storeAmanieu d'Antras-1/+1
2019-10-06Fix zero-size uninitialized boxesSimon Sapin-4/+14
Requesting a zero-size allocation is not allowed, return a dangling pointer instead. CC https://github.com/rust-lang/rust/issues/63291#issuecomment-538692745
2019-10-05Hide the `Iterator` specialization behind a traitJonas Schievink-5/+22
2019-10-05Deny specializing items not in the parent implJonas Schievink-0/+5
2019-10-03Rollup merge of #64975 - crgl:clone-from-linked-list, r=blussMazdak Farrokhzad-0/+56
Implement Clone::clone_from for LinkedList See #28481. This represents a substantial speedup when the list sizes are comparable, and shouldn't ever be significantly worse. Technically split_off is doing an unnecessary search, but the code is hopefully cleaner as a result. I'm happy to rework anything that needs to be changed as well!
2019-10-02Add test for LinkedList clone_fromCharles Gleason-0/+43
2019-10-02Use zipped iterators in clone_from for LinkedListCharles Gleason-2/+2
2019-10-02Stabilize `slice::repeat` (feature `repeat_generic_slice`)Lzu Tao-6/+1
2019-10-01Implement Clone::clone_from for LinkedListCharles Gleason-0/+13
2019-10-01Rollup merge of #64912 - lzutao:unneeded-main-doc, r=jonas-schievinkMazdak Farrokhzad-85/+54
Remove unneeded `fn main` blocks from docs ## [No whitespace diff](https://github.com/rust-lang/rust/pull/64912/files?w=1)
2019-10-01BTreeSet intersection, difference & is_subnet optimizationsStein Somers-93/+247
2019-10-01Remove unneeded `fn main` blocks from docsLzu Tao-85/+54
2019-09-30Rollup merge of #64893 - SimonSapin:vec-of-option-box, r=sfacklerTyler Mandry-0/+25
Zero-initialize `vec![None; n]` for `Option<&T>`, `Option<&mut T>` and `Option<Box<T>>`
2019-09-29Zero-initialize `vec![None; n]` for `Option<&T>`, `Option<&mut T>` and ↵Simon Sapin-0/+25
`Option<Box<T>>`
2019-09-29Fix `vec![x; n]` with null raw fat pointer zeroing the pointer metadataSimon Sapin-2/+50
https://github.com/rust-lang/rust/pull/49496 introduced specialization based on: ``` unsafe impl<T: ?Sized> IsZero for *mut T { fn is_zero(&self) -> bool { (*self).is_null() } } ``` … to call `RawVec::with_capacity_zeroed` for creating `Vec<*mut T>`, which is incorrect for fat pointers since `<*mut T>::is_null` only looks at the data component. That is, a fat pointer can be “null” without being made entirely of zero bits. This commit fixes it by removing the `?Sized` bound on this impl (and the corresponding `*const T` one). This regresses `vec![x; n]` with `x` a null raw slice of length zero, but that seems exceptionally uncommon. (Vtable pointers are never null, so raw trait objects would not take the fast path anyway. An alternative to keep the `?Sized` bound (or even generalize to `impl<U: Copy> IsZero for U`) would be to cast to `&[u8]` of length `size_of::<U>()`, but the optimizer seems not to be able to propagate alignment information and sticks with comparing one byte at a time: https://rust.godbolt.org/z/xQFkwL ---- Without the library change, the new test fails as follows: ``` ---- vec::vec_macro_repeating_null_raw_fat_pointer stdout ---- [src/liballoc/tests/vec.rs:1301] ptr_metadata(raw_dyn) = 0x00005596ef95f9a8 [src/liballoc/tests/vec.rs:1306] ptr_metadata(vec[0]) = 0x0000000000000000 thread 'vec::vec_macro_repeating_null_raw_fat_pointer' panicked at 'assertion failed: vec[0] == null_raw_dyn', src/liballoc/tests/vec.rs:1307:5 ```
2019-09-28Merge branch 'master' into format-temporariesJon Gjengset-2/+1
2019-09-27Scope format! temporariesJon Gjengset-1/+4
This places the temporaries that `format!` generates to refer to its arguments (through `&dyn Trait`) in a short-lived scope surrounding just the invocation of `format!`. This enables `format!` to be used in generators without the temporaries preventing the generator from being `Send` (due to `dyn Trait` not being `Sync`). See rust-lang/rust#64477 for details.
2019-09-27Stabilize map_get_key_value featureLzu Tao-2/+1
2019-09-25Snap cfgs to new betaMark Rousskov-5/+1
2019-09-24fix several issues in String docsjordins-4/+4
- In some places &str was shown instead of String. - into_bytes is the reverse of from_utf8 Fixes #63797
2019-09-20Exempt extern "Rust" from improper_ctypesJosh Stone-1/+1
It should be fine for Rust ABIs to involve any Rust type.
2019-09-16Const-stabilize `String::new`.Mazdak Farrokhzad-1/+1
2019-09-16Const-stabilize `Vec::new`.Mazdak Farrokhzad-4/+29
2019-09-16Auto merge of #64383 - pcpthm:btreeset-size-hint, r=dtolnaybors-22/+33
Improve BTreeSet::Intersection::size_hint A comment on `IntersectionInner` mentions `small_iter` should be smaller than `other_iter` but this condition is broken while iterating because those two iterators can be consumed at a different rate. I added a test to demonstrate this situation. <del>I made `small_iter.len() < other_iter.len()` always true by swapping two iterators when that condition became false. This change affects the return value of `size_hint`. The previous result was also correct but this new version always returns smaller upper bound than the previous version.</del> I changed `size_hint` to taking minimum of both lengths of iterators and renamed fields to `a` and `b` to match `Union` iterator.
2019-09-16Improve BTreeSet::Intersection::size_hintpcpthm-22/+33
The commented invariant that an iterator is smaller than other iterator was violated after next is called and two iterators are consumed at different rates.
2019-09-15Make the semantics of Vec::truncate(N) consistent with slices.gnzlbg-22/+12
This commit simplifies the implementation of `Vec::truncate(N)` and makes its semantics identical to dropping the `[vec.len() - N..]` sub-slice tail of the vector, which is the same behavior as dropping a vector containing the same sub-slice. This changes two unspecified aspects of `Vec::truncate` behavior: * the drop order, from back-to-front to front-to-back, * the behavior of `Vec::truncate` on panics: if dropping one element of the tail panics, currently, `Vec::truncate` panics, but with this PR all other elements are still dropped, and if dropping a second element of the tail panics, with this PR, the program aborts. Programs can trivially observe both changes. For example ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7bef575b83b06e82b3e3529e4edbcac7)): ```rust fn main() { struct Bomb(usize); impl Drop for Bomb { fn drop(&mut self) { panic!(format!("{}", self.0)); } } let mut v = vec![Bomb(0), Bomb(1)]; std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { v.truncate(0); })); assert_eq!(v.len(), 1); std::mem::forget(v); } ``` panics printing `1` today and succeeds. With this change, it panics printing `0` first (due to the drop order change), and then aborts with a double-panic printing `1`, just like dropping the `[Bomb(0), Bomb(1)]` slice does, or dropping `vec![Bomb(0), Bomb(1)]` does.
2019-09-14Rollup merge of #61797 - Thomasdezeeuw:stablise-weak_ptr_eq, r=RalfJungMazdak Farrokhzad-11/+8
Stabilise weak_ptr_eq Implemented in #55987. Closes #55981.
2019-09-14Rollup merge of #64375 - kornelski:vecdrop, r=rkruppeMazdak Farrokhzad-13/+17
Fast path for vec.clear/truncate For trivial types like `u8`, `vec.truncate()`/`vec.clear()` relies on the optimizer to remove the loop. This means more work in debug builds, and more work for the optimizer. Avoiding this busywork is exactly what `mem::needs_drop::<T>()` is for.
2019-09-14Rollup merge of #64203 - alexreg:rush-pr-2, r=centrilMazdak Farrokhzad-83/+81
A few cosmetic improvements to code & comments in liballoc and libcore Factored out from hacking on rustc for work on the REPL. r? @Centril