about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2017-09-04Make slice::split_at_mut example demonstrate mutabilityNiels Egberts-20/+25
Moved the examples from split_at_mut to split_at so the example at split_at_mut can just demonstrate mutability.
2017-09-03alloc: Implement downcast Rc<Any> -> Rc<T>Ulrik Sverdrup-0/+61
Implement downcast the like it exists for Box. The implementation avoids using into_raw/from_raw, because the pointer arithmetic which should cancel does not seem to optimize out at the moment. Since Rc<T> is never Send, only Rc<Any> and not Rc<Any + Send> implements downcast.
2017-08-30Rollup merge of #44160 - AndyGauge:api-docs-macros, r=steveklabnikAlex Crichton-7/+22
API docs: macros. Standard Documentation Checklist Fixes #29381 r? @steveklabnik
2017-08-30Rollup merge of #44044 - mattico:string-splice-return, r=dtolnayAlex Crichton-107/+24
Remove Splice struct return value from String::splice The implementation is now almost identical to the one in the RFC. Fixes #44038 cc #32310
2017-08-29broken links resolvedAndy Gauge-2/+2
2017-08-29API docs: macros. Part of #29329 Standard Library Documentation Checklist.Andy Gauge-7/+22
2017-08-29Auto merge of #44049 - alexcrichton:nounwind-allocators, r=BurntSushibors-0/+34
std: Mark allocation functions as nounwind This commit flags all allocation-related functions in liballoc as "this can't unwind" which should largely resolve the size-related issues found on #42808. The documentation on the trait was updated with such a restriction (they can't panic) as well as some other words about the relative instability about implementing a bullet-proof allocator. Closes #42808
2017-08-28Auto merge of #43076 - Zoxc:gen, r=arielb1bors-1/+13
Generator support This adds experimental support for generators intended to land once https://github.com/rust-lang/rfcs/pull/2033 is approved. This is not yet ready to be merged. Things to do: - [x] Make closure arguments on generators an error - [x] Spot FIXMEs - [x] Pass make tidy - [x] Write tests - [x] Document the current syntax and semantics for generators somewhere - [x] Use proper error message numbers - [x] ~~Make the implicit argument type default to `()`~~
2017-08-28std: Mark allocation functions as nounwindAlex Crichton-0/+34
This commit flags all allocation-related functions in liballoc as "this can't unwind" which should largely resolve the size-related issues found on #42808. The documentation on the trait was updated with such a restriction (they can't panic) as well as some other words about the relative instability about implementing a bullet-proof allocator. Closes #42808
2017-08-28Auto merge of #44114 - daboross:patch-1, r=dtolnaybors-2/+4
Clarify that VecDeque::swap can panic The previous documentation mentioned this, but ambiguously used the term "fail". This clarifies that the function will panic if the index is out of bounds, instead of silently failing and not doing anything. If there's anything else I can do to improve this PR, I'd be happy to do so! Just saw this when reading through the docs in passing - it was slightly unclear what "fail" meant.
2017-08-28Merge branch 'master' of https://github.com/rust-lang/rust into genJohn Kåre Alsaker-31/+25
2017-08-27Clarify that VecDeque::swap can panicDavid Ross-2/+4
The previous documentation mentioned this, but ambiguously used the term "fail". This clarifies that the function will panic if the index is out of bounds, instead of silently failing and not doing anything.
2017-08-27Move unused-extern-crate to late passTatsuyuki Ishi-5/+0
2017-08-26Remove Splice struct return value from String::spliceMatt Ickstadt-107/+24
2017-08-26Rollup merge of #44090 - GuillaumeGomez:str-doc, r=steveklabnikCorey Farwell-1/+2
Add missing link in string doc r? @rust-lang/docs
2017-08-26Rollup merge of #44072 - lukaramu:fix-doc-headings, r=steveklabnikCorey Farwell-23/+23
Fix inconsistent doc headings This fixes headings reading "Unsafety" and "Example", they should be "Safety" and "Examples" according to RFC 1574. r? @steveklabnik
2017-08-25Add missing link in string docGuillaume Gomez-1/+2
2017-08-25*: remove crate_{name,type} attributesTamir Duberstein-2/+0
Fixes #41701.
2017-08-25Merge remote-tracking branch 'origin/master' into genAlex Crichton-66/+612
2017-08-25Auto merge of #44031 - scottmcm:swap_with_slice, r=alexcrichtonbors-1/+26
Add [T]::swap_with_slice The safe version of a method from `ptr`, like `[T]::copy_from_slice` is. Tracking issue: https://github.com/rust-lang/rust/issues/44030
2017-08-24Fix inconsistent doc headingslukaramu-23/+23
This fixes headings reading "Unsafety" and "Example", they should be "Safety" and "Examples" according to RFC 1574.
2017-08-23Auto merge of #42565 - murarth:rc-from-slice, r=aturonbors-65/+586
Implement From<&[T]> and others for Arc/Rc (RFC 1845) * Implements `From<`{`&[T]`, `&str`, `String`, `Box<T> where T: ?Sized`, `Vec<T>`}`>` for `Arc`/`Rc` * Removes `rustc_private`-marked methods `Rc::__from_array` and `Rc::__from_str`, replacing their use with `Rc::from` Tracking issue: #40475
2017-08-21Add [T]::swap_with_sliceScott McMurray-1/+26
The safe version of a method from ptr, like [T]::copy_from_slice
2017-08-21Merge remote-tracking branch 'origin/master' into genAlex Crichton-33/+42
2017-08-19Implement `From<&[T]>` and others for `Arc`/`Rc`Murarth-65/+586
Implements RFC 1845, adding implementations of: * `From<&[T]>` for `Rc<[T]>` * `From<&str>` for `Rc<str>` * `From<String>` for `Rc<str>` * `From<Box<T: ?Sized>>` for `Rc<T>` * `From<Vec<T>>` for `Rc<[T]>` * and likewise for `Arc<_>` Also removes now-obsolete internal methods `Rc::__from_array` and `Rc::__from_str`, replacing their use with `Rc::from`.
2017-08-18Add missing links for String module and typeGuillaume Gomez-32/+41
2017-08-18Add missing url for fmt moduleGuillaume Gomez-1/+1
2017-08-17Merge remote-tracking branch 'origin/master' into genAlex Crichton-6/+6
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-6/+6
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-16Merge remote-tracking branch 'origin/master' into genAlex Crichton-38/+391
2017-08-16Auto merge of #43710 - zackmdavis:field_init_shorthand_power_slam, ↵bors-38/+38
r=Mark-Simulacrum use field init shorthand EVERYWHERE Like #43008 (f668999), but [(lacking reasons to be more timid)](https://github.com/rust-lang/rust/pull/43008#issuecomment-312463564) _much more aggressive_. r? @Mark-Simulacrum
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-38/+38
Like #43008 (f668999), but _much more aggressive_.
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