about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
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
2020-12-29refactor: moving AsIntoIter into into_iter.rsC-15/+16
2020-12-29refactor: moved IntoIter into into_iter.rsC-264/+276
2020-12-29refactor: moved Vec impl Cow into cow.rsC-35/+37
2020-12-29refactor: moving Drain into drain.rsC-147/+162
2020-12-29refactor: moving Splice into splice.rsC-128/+138
2020-12-29refactor: moving DrainFilter into drain_filter.rsC-138/+148
2020-12-29refactor: moving vec.rs to vec/mod.rsC-0/+0
2020-12-29Stabilize by-value `[T; N]` iterator `core::array::IntoIter`Simon Sapin-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/65798 This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135. This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method. `new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2020-12-28Rollup merge of #80448 - m-ou-se:deque-range-version, r=m-ou-seMara Bos-2/+2
Fix stabilization version of deque_range feature. See https://github.com/rust-lang/rust/pull/79022#issuecomment-751315315
2020-12-28Rollup merge of #80430 - xfix:add-length-as-doc-alias, r=steveklabnikMara Bos-0/+7
Add "length" as doc alias to len methods Currently when searching for `length` there are no results: https://doc.rust-lang.org/std/?search=length. This makes `len` methods appear when searching for `length`.
2020-12-28Rollup merge of #80398 - CAD97:fix-80365, r=dtolnayMara Bos-2/+2
Use raw version of align_of in rc data_offset This was missed in #73845 when switching to use the raw operators. Fixes #80365
2020-12-28Rollup merge of #80390 - ssomers:btree_cleanup_slices_2, r=Mark-SimulacrumMara Bos-50/+48
BTreeMap: rename the area access methods r? `@Mark-Simulacrum`
2020-12-28Fix stabilization version of deque_range feature.Mara Bos-2/+2
2020-12-28Mention Arc::make_mut and Rc::make_mut in the documentation of CowFrank Steffahn-0/+5
2020-12-28Rollup merge of #80353 - ssomers:btree_test_split_off, r=Mark-SimulacrumDylan DPC-7/+38
BTreeMap: test split_off (and append) more thoroughly Using DeterministicRng as a poor man's property based testing rig. r? ``@Mark-Simulacrum``
2020-12-28Add "length" as doc alias to len methodsKonrad Borowski-0/+7
2020-12-28de-stabilize unsized raw ptr methods for WeakRalf Jung-50/+6
2020-12-26Use raw version of align_of in rc data_offsetCAD97-2/+2
This was missed in #73845 when switching to use the raw operators. Fixes #80365
2020-12-26BTreeMap: rename the area access methodsStein Somers-50/+48