about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2021-06-14Stabilize `maybe_uninit_ref`Yuki Okushi-1/+0
2021-06-12Remove "generic type" in boxed.rsDeadbeef-1/+1
2021-06-09BTree: encapsulate LeafRange better & some debug assertsStein Somers-51/+111
2021-06-09Rollup merge of #85715 - fee1-dead:document-string, r=JohnTitorYuki Okushi-7/+43
Document `From` impls in string.rs
2021-06-08Mention the Borrow guarantee on the Hash implementations for Array and VecScott McMurray-0/+17
To remind people like me who forget about it and send PRs to make them different, and to (probably) get a test failure if the code is changed to no longer uphold it.
2021-06-08Auto merge of #83515 - tamird:string-remove-matches-rev, r=m-ou-sebors-22/+39
String::remove_matches O(n^2) -> O(n) Copy only non-matching bytes. Replace collection of matches into a vector with iteration over rejections, exploiting the guarantee that we mutate parts of the haystack that have already been searched over. r? `@joshtriplett`
2021-06-06String::remove_matches O(n^2) -> O(n)Tamir Duberstein-15/+38
Copy only non-matching bytes.
2021-06-06Use iter::from_fn in String::remove_matchesTamir Duberstein-9/+3
2021-06-06Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-seYuki Okushi-7/+6
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue #84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? ```@m-ou-se```
2021-06-05Document Arc::fromDeadbeef-0/+14
2021-06-04rustdoc: link to stable/beta docs consistently in documentationJoshua Nelson-1/+0
## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel
2021-06-04added back bindings_after_at as a cfg_attrmarcusdunn-0/+1
2021-06-04removed ref to bindings_after_atmarcusdunn-1/+0
2021-06-04Rollup merge of #85717 - fee1-dead:document-cow, r=yaahcYuki Okushi-0/+18
Document `From` impls for cow.rs
2021-06-03Auto merge of #85867 - steffahn:remove_unnecessary_specfromiter_impls, ↵bors-34/+1
r=Mark-Simulacrum Remove unnecessary SpecFromIter impls Unless I’m missing something, these `SpecFromIter<&'a T, …> for Vec<T>` implementations were completely unused.
2021-06-02Stabilize VecDeque::partition_point.Mara Bos-2/+1
2021-06-02Bump vecdeque_binary_search stabilization to 1.54.Mara Bos-3/+3
2021-06-02Bumped `vecdeque_binary_search` stabilization version to 1.53.0SOFe-3/+3
2021-06-02Stabilize `vecdeque_binary_search`SOFe-7/+3
2021-06-02Update expressions where we can use array's IntoIterator implementationMuhammad Mominul Huque-5/+5
2021-06-02Replace IntoIter::new with IntoIterator::into_iter in stdMuhammad Mominul Huque-2/+1
2021-05-31Update documentation of SpecFromIter to reflect the removed implsFrank Steffahn-3/+1
2021-05-31Remove unnecessary SpecFromIter implsFrank Steffahn-31/+0
2021-05-31Auto merge of #85814 - steffahn:fix_linked_list_itermut_debug, r=m-ou-sebors-7/+20
Fix unsoundness of Debug implementation for linked_list::IterMut Fix #85813, new `marker` field follows the example of `linked_list::Iter`.
2021-05-30Rollup merge of #85817 - r00ster91:patch-9, r=dtolnayGuillaume Gomez-1/+1
Fix a typo See also: #85737
2021-05-30Rollup merge of #85801 - WaffleLapkin:master, r=joshtriplettGuillaume Gomez-0/+37
Add `String::extend_from_within` This PR adds `String::extend_from_within` function under the `string_extend_from_within` feature gate similar to the [`Vec::extend_from_within`] function. ```rust // String pub fn extend_from_within<R>(&mut self, src: R) where R: RangeBounds<usize>; ``` [`Vec::extend_from_within`]: https://github.com/rust-lang/rust/issues/81656
2021-05-30Improve Debug impls for LinkedList reference iterators to show itemsFrank Steffahn-2/+18
2021-05-30Fix a typor00ster-1/+1
2021-05-29Fix unsoundness of Debug implementation for linked_list::IterMutFrank Steffahn-6/+3
2021-05-29Add `String::extend_from_within`Waffle-0/+37
This patch adds `String::extend_from_within` function under the `string_extend_from_within` feature gate similar to the `Vec::extend_from_within` function.
2021-05-27Revert "Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum"The8472-59/+25
Due to a performance regression that didn't show up in the original perf run this reverts commit 9111b8ae9793f18179a1336417618fc07a9cac85, reversing changes made to 9a700d2947f2d7f97a2c0dfca3117a8dcc255bdd.
2021-05-27Auto merge of #85737 - scottmcm:vec-calloc-option-nonzero, r=m-ou-sebors-0/+33
Enable Vec's calloc optimization for Option<NonZero> Someone on discord noticed that `vec![None::<NonZeroU32>; N]` wasn't getting the optimization, so here's a PR šŸ™ƒ We can certainly do this in the standard library because we know for sure this is ok, but I think it's also a necessary consequence of documented guarantees like those in https://doc.rust-lang.org/std/option/#representation and https://doc.rust-lang.org/core/num/struct.NonZeroU32.html It feels weird to do this without adding a test, but I wasn't sure where that would belong. Is it worth adding codegen tests for these?
2021-05-26Enable Vec's calloc optimization for Option<NonZero>Scott McMurray-0/+33
2021-05-26Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrumbors-25/+59
Add `TrustedRandomAccess` specialization for `Vec::extend()` This should do roughly the same as the `TrustedLen` specialization but result in less IR by using `__iterator_get_unchecked` instead of `Iterator::for_each` Conflicting specializations are manually prioritized by grouping them under yet another helper trait.
2021-05-26Document `From` impls for cow.rsDeadbeef-0/+18
2021-05-26Rollup merge of #85625 - SkiFire13:fix-85613-vec-dedup-drop-panics, r=nagisaDylan DPC-2/+3
Prevent double drop in `Vec::dedup_by` if a destructor panics Fixes #85613
2021-05-26Document `From` impls in string.rsDeadbeef-7/+43
2021-05-26Rollup merge of #85666 - fee1-dead:document-shared-from-cow, r=dtolnayYuki Okushi-0/+24
Document shared_from_cow functions
2021-05-26Auto merge of #85535 - dtolnay:weakdangle, r=kennytmbors-2/+2
Weak's type parameter may dangle on drop Way back in https://github.com/rust-lang/rust/commit/34076bc0c9fb9ee718e1cebc407547eef730a080, #\[may_dangle\] was added to Rc\<T\> and Arc\<T\>'s Drop impls. That appears to have been because a test added in #28929 used Arc and Rc with dangling references at drop time. However, Weak was not covered by that test, and therefore no #\[may_dangle\] was forced to be added at the time. As far as dropping, Weak has *even less need* to interact with the T than Rc and Arc do. Roughly speaking #\[may_dangle\] describes generic parameters that the outer type's Drop impl does not interact with except by possibly dropping them; no other interaction (such as trait method calls on the generic type) is permissible. It's clear this applies to Rc's and Arc's drop impl, which sometimes drop T but otherwise do not interact with one. It applies *even more* to Weak. Dropping a Weak cannot ever cause T's drop impl to run. Either there are strong references still in existence, in which case better not drop the T. Or there are no strong references still in existence, in which case the T would already have been dropped previously by the drop of the last strong count.
2021-05-25Document shared_from_cow functionsDeadbeef-0/+24
2021-05-24remove cfg(bootstrap)Pietro Albini-3/+1
2021-05-24Avoid a double drop in Vec::dedup if a destructor panicsGiacomo Stevanato-2/+3
2021-05-21Remove surplus prepend LinkedList fnJubilee Young-21/+0
Originally committed to Rust in 2013, it is identical to append with a reversed order of arguments.
2021-05-20Weak's type parameter may dangle on dropDavid Tolnay-2/+2
2021-05-20Auto merge of #85391 - Mark-Simulacrum:opt-tostring, r=scottmcmbors-2/+3
Avoid zero-length memcpy in formatting This has two separate and somewhat orthogonal commits. The first change adjusts the ToString general impl for all types that implement Display; it no longer uses the full format machinery, rather directly falling onto a `std::fmt::Display::fmt` call. The second change directly adjusts the general core::fmt::write function which handles the production of format_args! to avoid zero-length push_str calls. Both changes target the fact that push_str will still call memmove internally (or a similar function), as it doesn't know the length of the passed string. For zero-length strings in particular, this is quite expensive, and even for very short (several bytes long) strings, this is also expensive. Future work in this area may wish to have us fallback to write_char or similar, which may be cheaper on the (typically) short strings between the interpolated pieces in format_args!.
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-3/+4
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-17Optimize default ToString implMark Rousskov-2/+3
This avoids a zero-length write_str call, which boils down to a zero-length memmove and ultimately costs quite a few instructions on some workloads. This is approximately a 0.33% instruction count win on diesel-check.
2021-05-16mark internal inplace_iteration traits as hiddenThe8472-0/+4
2021-05-11Auto merge of #84904 - ssomers:btree_drop_kv_in_place, r=Mark-Simulacrumbors-45/+95
BTree: no longer copy keys and values before dropping them When dropping BTreeMap or BTreeSet instances, keys-value pairs are up to now each copied and then dropped, at least according to source code. This is because the code for dropping and for iterators is shared. This PR postpones the treatment of doomed key-value pairs from the intermediate functions `deallocating_next`(`_back`) to the last minute, so the we can drop the keys and values in place. According to the library/alloc benchmarks, this does make a difference, (and a positive difference with an `#[inline]` on `drop_key_val`). It does not change anything for #81444 though. r? `@Mark-Simulacrum`
2021-05-10Document Rc::fromDeadbeef-0/+13