about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2021-01-11Specialize Rc/Arc::make_mut clones to try to avoid localsJosh Stone-5/+18
As we did with `Box`, we can allocate an uninitialized `Rc` or `Arc` beforehand, giving the optimizer a chance to skip the local value for regular clones, or avoid any local altogether for `T: Copy`.
2021-01-11Specialize Box clones to try to avoid localsJosh Stone-2/+28
For generic `T: Clone`, we can allocate an uninitialized box beforehand, which gives the optimizer a chance to create the clone directly in the heap. For `T: Copy`, we can go further and do a simple memory copy, regardless of optimization level.
2021-01-10Weak::into_raw shouldn't translate sentinel valueCAD97-27/+21
2021-01-11Add another test case for #79808Yuki Okushi-0/+15
Taken from #80293.
2021-01-10BTreeMap: tougher checks on code using raw into_kv_pointersStein Somers-81/+88
2021-01-10Auto merge of #80391 - ssomers:btree_cleanup_slices_3, r=Mark-Simulacrumbors-26/+32
BTreeMap: tougher checking on most uses of copy_nonoverlapping Miri checks pointer provenance and destination, but we can check it in debug builds already. Also, we can let Miri confirm we don't mistake imprints of moved keys and values as genuine. r? `@Mark-Simulacrum`
2021-01-09Add comment to `Vec::truncate` explaining `>` vs `>=`Camelid-0/+3
Hopefully this will prevent people from continuing to ask about this over and over again :) See [this Zulip discussion][1] for more. [1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation
2021-01-09Provide reasoning for rc data_offset safetyCAD97-8/+12
2021-01-08BTreeMap: tougher checks on most uses of copy_nonoverlappingStein Somers-26/+32
2021-01-07Replace set_data_ptr with pointer::set_ptr_valueCAD97-32/+5
2021-01-07Reclarify Weak<->raw pointer safety commentsCAD97-4/+4
2021-01-07Remove "pointer describes" terminologyCAD97-10/+8
2021-01-07Tighten/clarify documentation of rc data_offsetCAD97-10/+4
2021-01-06Re-stabilize Weak::as_ptr &friends for unsized TCAD97-35/+130
As per T-lang consensus, this uses a branch to handle the dangling case. The discussed optimization of only doing the branch in the T: ?Sized case is left for a followup patch, as doing so is not trivial (as it requires specialization for correctness, not just optimization).
2021-01-05Rollup merge of #80666 - jjlin:master, r=Dylan-DPCYuki Okushi-0/+1
Fix missing link for "fully qualified syntax" This issue can currently be seen at https://doc.rust-lang.org/stable/std/rc/index.html#toggle-all-docs:~:text=%5B-,fully%20qualified%20syntax It originates from #76138, where the link was added to `library/alloc/src/sync.rs`, but not `library/alloc/src/rc.rs`.
2021-01-05Rollup merge of #80442 - steffahn:mention_arc_in_cow, r=Mark-SimulacrumYuki Okushi-0/+5
Mention Arc::make_mut and Rc::make_mut in the documentation of Cow Following this discussion: https://users.rust-lang.org/t/should-the-cow-documentation-mention-arc/53341 _Rendered (the last paragraph is new):_ ![Screenshot_20201228_171551](https://user-images.githubusercontent.com/3986214/103228135-5d72e200-4930-11eb-89e1-38b5c86b08c7.png) `@rustbot` modify labels: T-doc, T-libs
2021-01-03Fix missing link for "fully qualified syntax"Jeremy Lin-0/+1
2021-01-03Rollup merge of #80591 - lcnr:incomplete-features, r=RalfJungGuillaume Gomez-2/+1
remove allow(incomplete_features) from std cc https://github.com/rust-lang/rust/pull/80349#issuecomment-753357123 > Now I am somewhat concerned that the standard library uses some of these features... I think it is theoretically ok to use incomplete features in the standard library or the compiler if we know that there is an already working subset and we explicitly document what we have to be careful about. Though at that point it is probably better to try and split the incomplete feature into two separate ones, similar to `min_specialization`. Will be interesting once `feature(const_evaluatable_checked)` works well enough to imo be used in the compiler but not yet well enough to be removed from `INCOMPLETE_FEATURES`. r? `@RalfJung`
2021-01-02Auto merge of #77832 - camelid:remove-manual-link-resolves, r=jyn514bors-4/+0
Remove many unnecessary manual link resolves from library Now that #76934 has merged, we can remove a lot of these! E.g, this is no longer necessary: [`Vec<T>`]: Vec cc `@jyn514`
2021-01-01Improve grammar in documentation of format stringsFrank Steffahn-4/+5
2021-01-01remove incomplete features from stdBastian Kauschke-2/+1
2021-01-01Auto merge of #80310 - Manishearth:box-try-alloc, r=kennytmbors-10/+389
Add fallible Box, Arc, and Rc allocator APIs cc https://github.com/rust-lang/rust/issues/48043 It was suggested in https://github.com/rust-lang/rust/issues/48043#issuecomment-748008486 that `Box::try_*` follows the spirit of RFC 2116. This PR is an attempt to add the relevant APIs, tied to the same feature gate. Happy to make any changes or turn this into an RFC if necessary. cc `@rust-lang/wg-allocators`
2020-12-31Remove many unnecessary manual link resolves from libraryCamelid-4/+0
Now that #76934 has merged, we can remove a lot of these! E.g, this is no longer necessary: [`Vec<T>`]: Vec
2020-12-31More inline, doc fixesManish Goregaokar-2/+3
2020-12-31Make [A]Rc::allocate_for_layout() use try_allocate_for_layout()Manish Goregaokar-23/+5
2020-12-31Auto merge of #79895 - Kerollmops:slice-group-by, r=m-ou-sebors-0/+3
The return of the GroupBy and GroupByMut iterators on slice According to https://github.com/rust-lang/rfcs/pull/2477#issuecomment-742034372, I am opening this PR again, this time I implemented it in safe Rust only, it is therefore much easier to read and is completely safe. This PR proposes to add two new methods to the slice, the `group_by` and `group_by_mut`. These two methods provide a way to iterate over non-overlapping sub-slices of a base slice that are separated by the predicate given by the user (e.g. `Partial::eq`, `|a, b| a.abs() < b.abs()`). ```rust let slice = &[1, 1, 1, 3, 3, 2, 2, 2]; let mut iter = slice.group_by(|a, b| a == b); assert_eq!(iter.next(), Some(&[1, 1, 1][..])); assert_eq!(iter.next(), Some(&[3, 3][..])); assert_eq!(iter.next(), Some(&[2, 2, 2][..])); assert_eq!(iter.next(), None); ``` [An RFC](https://github.com/rust-lang/rfcs/pull/2477) was open 2 years ago but wasn't necessary.
2020-12-31Replace the tracking issue for the slice_group_by featureClément Renault-1/+1
2020-12-31Reuse Box::try_new_*_in() in Box::new_*_in()Manish Goregaokar-5/+2
2020-12-31Add fallible Arc APIs (`Arc::try_new_*`)Manish Goregaokar-0/+122
2020-12-31Add fallible Rc APIs (`Rc::try_new_*`)Manish Goregaokar-22/+121
2020-12-31Add fallible box APIs (`Box::try_new_*`)Manish Goregaokar-1/+95
2020-12-31Add fallible box allocator APIs (`Box::try_new_*_in()`)Manish Goregaokar-1/+85
2020-12-30Auto merge of #80530 - m-ou-se:rollup-zit69ko, r=m-ou-sebors-1270/+1376
Rollup of 9 pull requests Successful merges: - #78934 (refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength) - #79479 (Add `Iterator::intersperse`) - #80128 (Edit rustc_ast::ast::FieldPat docs) - #80424 (Don't give an error when creating a file for the first time) - #80458 (Some Promotion Refactoring) - #80488 (Do not create dangling &T in Weak<T>::drop) - #80491 (Miri: make size/align_of_val work for dangling raw ptrs) - #80495 (Rename kw::Invalid -> kw::Empty) - #80513 (Add regression test for #80062) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-30Rollup merge of #80488 - CAD97:drop-weak-without-reference, r=m-ou-seMara Bos-2/+2
Do not create dangling &T in Weak<T>::drop Since at this point all strong pointers have been dropped, the wrapped `T` has also been dropped. As such, creating a `&T` to the dropped place is negligent at best (language UB at worst). Since we have `Layout::for_value_raw` now, use that instead of `Layout::for_value` to avoid creating the `&T`. This does have implications for custom (potentially thin) DSTs, though much less severe than those discussed in #80407. Specifically, one of two things has to be true: - It has to be possible to use a `*const T` to a dropped (potentially custom, potentially thin) unsized tailed object to determine the layout (size/align) of the object. This is what is currently implemented (though with `&T` instead of `&T`). The validity of reading some location after it has been dropped is an open question IIUC (https://github.com/rust-lang/unsafe-code-guidelines/issues/188) (except when the whole type is `Copy`, per `drop_in_place`'s docs). In this design, custom DSTs would get a `*mut T` and use that to return layout, and must be able to do so while in the "zombie" (post-drop, pre-free) state. - `RcBox`/`ArcInner` compute and store layout eagerly, so that they don't have to ask the type for its layout after dropping it. Importantly, this is already true today, as you can construct `Rc<DST>`, create a `Weak<DST>`, and drop the `Rc` before the `Weak`. This PR is a strict improvement over the status quo, and the above question about potentially thin DSTs will need to be resolved by any custom DST proposal.
2020-12-30Fix rustdoc link in vec/into_iter.rs.Mara Bos-2/+2
2020-12-30Bump bootstrap compiler to 1.50 betaMark Rousskov-2/+1
2020-12-29Do not create dangling &T in Weak<T>::dropCAD97-2/+2
2020-12-29docs: fixing referencesC-1/+1
2020-12-29fix: moved import into #[cfg(test)]C-2/+1
2020-12-29style: applying Rust styleC-80/+74
2020-12-29refactor: removing // ignore-tidy-filelengthC-1/+0
2020-12-29refactor: moved SpecExtend into spec_extend.rsC-79/+87
2020-12-29refactor: moving SpecFromIter into spec_from_iter.rsC-92/+102
2020-12-29refactor: moved SpecFromIterNested to spec_from_iter_nested.rsC-52/+60
2020-12-29refactor: moved InPlaceDrop into in_place_drop.rsC-22/+28
2020-12-29refactor: moved SetLenOnDrop to set_len_on_dropC-29/+32
2020-12-29refactor: moved SpecFromElem to spec_from_elem.rsC-55/+64
2020-12-29refactor: moved PartialEq into partial_eqC-39/+45
2020-12-29refactor: moving SourceIterMarker into source_iter_marker.rsC-104/+113
2020-12-29refactor: moved IsZero into is_zero.rsC-70/+75