about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2017-08-15Auto merge of #43245 - Gankro:drain-filter, r=sfacklerbors-0/+281
Add Vec::drain_filter This implements the API proposed in #43244. So I spent like half a day figuring out how to implement this in some awesome super-optimized unsafe way, which had me very confident this was worth putting into the stdlib. Then I looked at the impl for `retain`, and was like "oh dang". I compared the two and they basically ended up being the same speed. And the `retain` impl probably translates to DoubleEndedIter a lot more cleanly if we ever want that. So now I'm not totally confident this needs to go in the stdlib, but I've got two implementations and an amazingly robust test suite, so I figured I might as well toss it over the fence for discussion.
2017-08-15Fix typos & us spellingsFourchaux-6/+6
2017-08-15Auto merge of #43500 - murarth:string-retain, r=alexcrichtonbors-0/+72
Add method `String::retain` Behaves like `Vec::retain`, accepting a predicate `FnMut(char) -> bool` and reducing the string to only characters for which the predicate returns `true`.
2017-08-14Add method `String::retain`Murarth-0/+72
Behaves like `Vec::retain`, accepting a predicate `FnMut(char) -> bool` and reducing the string to only characters for which the predicate returns `true`.
2017-08-14Merge remote-tracking branch 'origin/master' into genAlex Crichton-121/+203
2017-08-13Auto merge of #43815 - alexcrichton:optimize-alloc, r=sfacklerbors-76/+133
Optimize allocation paths in RawVec Since the `Alloc` trait was introduced (https://github.com/rust-lang/rust/pull/42313) and it was integrated everywhere (https://github.com/rust-lang/rust/pull/42727) there's been some slowdowns and regressions that have slipped through. The intention of this PR is to try to tackle at least some of them, but they've been very difficult to quantify up to this point so it probably doesn't solve everything. This PR primarily targets the `RawVec` type, specifically the `double` function. The codegen for this function is now much closer to what it was before #42313 landed as many runtime checks have been elided.
2017-08-13Rollup merge of #43814 - Eijebong:fix_typos2, r=petrochenkovGuillaume Gomez-5/+5
Fix some typos Follow up of #43794 If refined my script a little bit and found some more.
2017-08-13Rollup merge of #43803 - GuillaumeGomez:missing-links-doc, r=frewsxcvGuillaume Gomez-37/+62
Missing links doc r? @rust-lang/docs
2017-08-12std: Unsafe-away runtime checks in `Vec`Alex Crichton-76/+127
The `RawVec` type has a number of invariants that it upholds throughout its execution, and as a result many of the runtime checks imposed by using `Layout` in a "raw" fashion aren't actually necessary. For example a `RawVec`'s capacity is intended to always match the layout which "fits" the allocation, so we don't need any runtime checks when retrieving the current `Layout` for a vector. Consequently, this adds a safe `current_layout` function which internally uses the `from_size_align_unchecked` function. Along the same lines we know that most construction of new layouts will not overflow. All allocations in `RawVec` are kept below `isize::MAX` and valid alignments are also kept low enough that we're guaranteed that `Layout` for a doubled vector will never overflow and will always succeed construction. Consequently a few locations can use `from_size_align_unchecked` in addition when constructing the *new* layout to allocate (or reallocate), which allows for eliding some more runtime checks. Overall this should significant improve performance for an important function, `RawVec::double`. This commit removes four runtime jumps before `__rust_realloc` is called, as well as one after it's called.
2017-08-12Add missing link in fmt::format functionGuillaume Gomez-20/+22
2017-08-12Fix some typosBastien Orivel-5/+5
2017-08-12Auto merge of #43794 - Eijebong:fix_typos, r=lukaramu,steveklanik,imperiobors-3/+3
Fix some typos I wrote a really naive script and found those typos in the documentation.
2017-08-11std: Tag OOM functions as `#[cold]`Alex Crichton-0/+2
This was forgotten from #42727 by accident, but these functions are rarely called and codegen can be improved in LLVM with the `#[cold]` tag.
2017-08-11std: Tag `AllocErr` functions as `#[inline]`Alex Crichton-0/+4
None of these require a significant amount of code and using `#[inline]` will allow constructors to get inlined, improving codegen at allocation callsites.
2017-08-11Merge remote-tracking branch 'origin/master' into genAlex Crichton-3/+33
2017-08-11Add (a lot of) missing links in fmt module docsGuillaume Gomez-32/+55
2017-08-11Rollup merge of #43793 - j-browne:master, r=steveklabnikGuillaume Gomez-1/+1
Fix broken links in Arc documentation Some link references had ticks, when they should not have had them.
2017-08-11Rollup merge of #43721 - natboehm:patch-1, r=steveklabnikGuillaume Gomez-2/+32
Provide more explanation for Deref in String docs While working on a different project I encountered a point of confusion where using `&String` to dereference a `String` into `&str` did not compile. I found the explanation of [String Deref](https://doc.rust-lang.org/std/string/struct.String.html#deref), thought that it matched what I was trying to do, and was confused as to why my program did not compile when the docs stated that it would work with 'any function which takes a `&str`'. At the bottom it is mentioned that this will 'generally' work, unless `String` is needed, but I found this statement confusing based on the previous claim of 'any'. Looking further into the docs I was able to find the function `as_str()` that works instead. I thought it might be helpful to mention here deref coercion, an instance in which using `&String` does not work, to explain why it does not work, then direct users to a different option that should work in this instance. A user casually skimming the page will likely come to this explanation first, then find `as_str()` later, but be no the wiser as to what potentially went wrong. r? @steveklabnik
2017-08-11Fix some typosBastien Orivel-3/+3
2017-08-10Fix broken links in Arc documentationJustin Browne-1/+1
2017-08-10Merge remote-tracking branch 'origin/master' into genAlex Crichton-6/+6
2017-08-10Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1bors-6/+6
Fixed mutable vars being marked used when they weren't #### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue. Fixes #43526, Fixes #30280, Fixes #25049 ### Issue Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings ``` fn do_thing<T>(mut arg : &mut T) { ... // don't touch arg - just deref it to access the T } ``` ### Fix Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables. #### Why not on things other than local variables? * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted. * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-11/+33
2017-08-08Fix trait name `Deref`Natalie Boehm-1/+1
2017-08-08Update solution to add using `&*` as well as `as_str()`Natalie Boehm-4/+9
2017-08-07Update explanation of deref coercionNatalie Boehm-8/+10
2017-08-05Indicate how to turn byte slices back into a string slice.Corey Farwell-2/+9
2017-08-05Update str::split_at_mut example to demonstrate mutability.Corey Farwell-6/+10
2017-08-04Update String Deref to explain why using &String does not always workNatalie Boehm-2/+25
2017-08-04Indicate why str::{get,get_mut} examples return None.Corey Farwell-5/+15
2017-08-01Fixed extra cases found in better checking.Isaac van Bakel-2/+2
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-4/+4
2017-07-29Rollup merge of #43513 - alexcrichton:inline-repeat, r=BurntSushiMark Simulacrum-0/+1
std: Mark `Layout::repeat` as `#[inline]` This fixes an optimization regression by allowing LLVM to see through more functions. Closes #43272
2017-07-29std: Mark `Layout::repeat` as `#[inline]`Alex Crichton-0/+1
This fixes an optimization regression by allowing LLVM to see through more functions. Closes #43272
2017-07-28Rename State to GeneratorStateJohn Kåre Alsaker-2/+2
2017-07-28Remove support for `gen arg`Alex Crichton-4/+4
2017-07-28Fill in generator tracking issue in a few more locationsAlex Crichton-1/+1
2017-07-28Fix testsAlex Crichton-1/+1
2017-07-28std: Add forwarding impls of `Generator` traitAlex Crichton-1/+13
2017-07-28Auto merge of #43217 - pnkfelix:alloc-requires-align-it-in-u32, r=alexcrichtonbors-7/+15
Add precondition to `Layout` that the `align` fit in a u32. Add precondition to `Layout` that the `align` not exceed 2^31. This precondition takes the form of a behavorial change in `Layout::from_size_align` (so it returns `None` if the input `align` is too large) and a new requirement for safe usage of `Layout::from_size_align_unchecked`. Fix #30170.
2017-07-26Auto merge of #43373 - alexcrichton:stabilize-1.20.0, r=aturonbors-17/+7
Stabilize more APIs for the 1.20.0 release In addition to the few stabilizations that have already landed, this cleans up the remaining APIs that are in `final-comment-period` right now to be stable by the 1.20.0 release
2017-07-26Rollup merge of #43455 - QuietMisdreavus:extend-spec-docs, r=steveklabnikMark Simulacrum-0/+6
add a note to Vec's Extend<&T> impl about its slice specialization From the regular documentation view, it's not at all apparent that [this specialization](https://github.com/rust-lang/rust/blob/5669c9988f50788b5ab5dee2d4538519d4e5663d/src/liballoc/vec.rs#L1879-L1891) exists for `slice::Iter`. This adds a documentation blurb to the Extend impl itself to note that this optimization exists.
2017-07-26Rollup merge of #42959 - SimonSapin:nonzero-checked, r=sfacklerMark Simulacrum-43/+68
Make the "main" constructors of NonZero/Shared/Unique return Option Per discussion in https://github.com/rust-lang/rust/issues/27730#issuecomment-303939441. This is a breaking change to unstable APIs. The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts. In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
2017-07-25add a note to Vec's Extend<&T> impl about its slice specializationQuietMisdreavus-0/+6
2017-07-25std: Stabilize the `str_{mut,box}_extras` featureAlex Crichton-4/+3
Stabilizes * `<&mut str>::as_bytes_mut` * `<Box<str>>::into_boxed_bytes` * `std::str::from_boxed_utf8_unchecked` * `std::str::from_utf8_mut` * `std::str::from_utf8_unchecked_mut` Closes #41119
2017-07-25std: Stabilize `manually_drop` featureAlex Crichton-1/+0
Stabilizes * `core::mem::ManuallyDrop` * `std::mem::ManuallyDrop` * `ManuallyDrop::new` * `ManuallyDrop::into_inner` * `ManuallyDrop::drop` * `Deref for ManuallyDrop` * `DerefMut for ManuallyDrop` Closes #40673
2017-07-25std: Stabilize `utf8_error_error_len` featureAlex Crichton-1/+0
Stabilizes: * `Utf8Error::error_len` Closes #40494
2017-07-25std: Stabilize `str_checked_slicing` featureAlex Crichton-10/+4
Stabilized * `<str>::get` * `<str>::get_mut` * `<str>::get_unchecked` * `<str>::get_unchecked_mut` Closes #39932
2017-07-25std: Stabilize `char_escape_debug`Alex Crichton-1/+0
Stabilizes: * `<char>::escape_debug` * `std::char::EscapeDebug` Closes #35068
2017-07-25Bump master to 1.21.0Alex Crichton-2/+1
This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.