about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2021-03-04Alternative LUT rather than dividing.Giles Cope-1/+34
2021-03-03BTree: move blocks around in node.rsStein Somers-167/+165
2021-03-03Update library/alloc/src/vec/mod.rsWaffle Lapkin-1/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-03Fix ui-full-deps suiteRyan Levick-4/+4
2021-03-03Rollup merge of #82439 - ssomers:btree_fix_unsafety, r=Mark-SimulacrumYuki Okushi-16/+15
BTree: fix untrue safety Fix needless and missing `unsafe` tags. r? ````@Mark-Simulacrum````
2021-03-03Make Vec::split_at_spare_mut impl safer & simplierWaffle-9/+5
2021-03-02Auto merge of #82043 - tmiasko:may-have-side-effect, r=kennytmbors-3/+1
Turn may_have_side_effect into an associated constant The `may_have_side_effect` is an implementation detail of `TrustedRandomAccess` trait. It describes if obtaining an iterator element may have side effects. It is currently implemented as an associated function. Turn `may_have_side_effect` into an associated constant. This makes the value immediately available to the optimizer.
2021-03-02Rollup merge of #80189 - jyn514:convert-primitives, r=poliorceticsYuki Okushi-17/+20
Convert primitives in the standard library to intra-doc links Blocked on https://github.com/rust-lang/rust/pull/80181. I forgot that this needs to wait for the beta bump so the standard library can be documented with `doc --stage 0`. Notably I didn't convert `core::slice` because it's like 50 links and I got scared :fearful:
2021-03-01Rollup merge of #82578 - camsteffen:diag-items, r=oli-obkJoshua Nelson-0/+4
Add some diagnostic items for Clippy
2021-03-01Rollup merge of #81210 - ssomers:btree_fix_node_size_test, r=Mark-SimulacrumJoshua Nelson-5/+6
BTreeMap: correct node size test case for choices of B r? `@Mark-Simulacrum`
2021-03-01Add diagnostic itemsCameron Steffen-0/+4
2021-03-01Auto merge of #82440 - ssomers:btree_fix_casts, r=Mark-Simulacrumbors-8/+10
BTree: no longer define impossible casts Casts to leaf to internal only make sense when the original has a chance of being the thing it's cast to. r? `@Mark-Simulacrum`
2021-03-01Auto merge of #81094 - ssomers:btree_drainy_refactor_3, r=Mark-Simulacrumbors-118/+228
BTreeMap: split up range_search into two stages `range_search` expects the caller to pass the same root twice and starts searching a node for both bounds of a range. It's not very clear that in the early iterations, it searches twice in the same node. This PR splits that search up in an initial `find_leaf_edges_spanning_range` that postpones aliasing until the last second, and a second phase for continuing the search for the range in the each subtree independently (`find_lower_bound_edge` & `find_upper_bound_edge`), which greatly helps for use in #81075. It also moves those functions over to the search module. r? `@Mark-Simulacrum`
2021-02-27u8::to_string() specialisation (far less asm).Giles Cope-0/+19
2021-02-27Revert `Vec::spare_capacity_mut` impl to prevent pointers invalidationWaffle-1/+9
2021-02-26Fix invalid slice access in String::retainGiacomo Stevanato-15/+22
2021-02-25Convert primitives to use intra-doc linksJoshua Nelson-17/+20
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-10/+11
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-23Rollup merge of #82113 - m-ou-se:panic-format-lint, r=estebankDylan DPC-0/+1
Improve non_fmt_panic lint. This change: - fixes the span used by this lint in the case the panic argument is a single macro expansion (e.g. `panic!(a!())`); - adds a suggestion for `panic!(format!(..))` to remove `format!()` instead of adding `"{}", ` or using `panic_any` like it does now; and - fixes the incorrect suggestion to replace `panic![123]` by `panic_any(123]`. Fixes #82109. Fixes #82110. Fixes #82111. Example output: ``` warning: panic message is not a string literal --> src/main.rs:8:12 | 8 | panic!(format!("error: {}", "oh no")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(non_fmt_panic)]` on by default = note: this is no longer accepted in Rust 2021 = note: the panic!() macro supports formatting, so there's no need for the format!() macro here help: remove the `format!(..)` macro call | 8 | panic!("error: {}", "oh no"); | -- -- ``` r? `@estebank`
2021-02-23BTree: fix untrue safetyStein Somers-16/+15
2021-02-23BTree: no longer define impossible castsStein Somers-8/+10
2021-02-23BTree: split off reusable components from range_searchStein Somers-118/+228
2021-02-23Auto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrumbors-5/+0
Update the bootstrap compiler This updates the bootstrap compiler, notably leaving out a change to enable semicolon in macro expressions lint, because stdarch still depends on the old behavior.
2021-02-23Add more links between hash and btree collectionsJoshua Nelson-3/+4
- Link from `core::hash` to `HashMap` and `HashSet` - Link from HashMap and HashSet to the module-level documentation on when to use the collection - Link from several collections to Wikipedia articles on the general concept
2021-02-23Auto merge of #82430 - Dylan-DPC:rollup-nu4kfyc, r=Dylan-DPCbors-7/+13
Rollup of 12 pull requests Successful merges: - #79423 (Enable smart punctuation) - #81154 (Improve design of `assert_len`) - #81235 (Improve suggestion for tuple struct pattern matching errors.) - #81769 (Suggest `return`ing tail expressions that match return type) - #81837 (Slight perf improvement on char::to_ascii_lowercase) - #81969 (Avoid `cfg_if` in `std::os`) - #81984 (Make WASI's `hard_link` behavior match other platforms.) - #82091 (use PlaceRef abstractions more consistently) - #82128 (add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice) - #82166 (add s390x-unknown-linux-musl target) - #82234 (Remove query parameters when skipping search results) - #82255 (Make `treat_err_as_bug` Option<NonZeroUsize>) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-23Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwcoDylan DPC-0/+3
add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature. Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-23Rollup merge of #81154 - dylni:improve-design-of-assert-len, r=KodrAusDylan DPC-7/+10
Improve design of `assert_len` It was discussed in the [tracking issue](https://github.com/rust-lang/rust/issues/76393#issuecomment-761765448) that `assert_len`'s name and usage are confusing. This PR improves them based on a suggestion by ``@scottmcm`` in that issue. I also improved the documentation to make it clearer when you might want to use this method. Old example: ```rust let range = range.assert_len(slice.len()); ``` New example: ```rust let range = range.ensure_subset_of(..slice.len()); ``` Fixes #81157
2021-02-23Auto merge of #81937 - ssomers:btree_drainy_refactor_9b, r=Mark-Simulacrumbors-98/+67
BTree: move more shared iterator code into navigate.rs The functions in navigate.rs only exist to support iterators, and these look easier on my eyes if there is a shared `struct` with the recurring pair of handles. r? `@Mark-Simulacrum`
2021-02-22Auto merge of #81362 - ssomers:btree_drainy_refactor_8, r=Mark-Simulacrumbors-146/+176
BTreeMap: gather and decompose reusable tree fixing functions This is kind of pushing it as a standalone refactor, probably only useful for #81075 (or similar). r? `@Mark-Simulacrum`
2021-02-21BTreeMap: correct tests for alternative choices of BStein Somers-5/+6
2021-02-21Improve sift_down performance in BinaryHeapHan Mertens-2/+2
Because child > 0, the two statements are equivalent, but using saturating_sub and <= yields in faster code. This is most notable in the binary_heap::bench_into_sorted_vec benchmark, which shows a speedup of 1.26x, which uses sift_down_range internally. The speedup of pop (that uses sift_down_to_bottom internally) is much less significant as the sifting method is not called in a loop.
2021-02-21Rollup merge of #81706 - SkiFire13:document-binaryheap-unsafe, r=Mark-SimulacrumYuki Okushi-49/+117
Document BinaryHeap unsafe functions `BinaryHeap` contains some private safe functions but that are actually unsafe to call. This PR marks them `unsafe` and documents all the `unsafe` function calls inside them. While doing this I might also have found a bug: some "SAFETY" comments in `sift_down_range` and `sift_down_to_bottom` are valid only if you assume that `child` doesn't overflow. However it may overflow if `end > isize::MAX` which can be true for ZSTs (but I think only for them). I guess the easiest fix would be to skip any sifting if `mem::size_of::<T> == 0`. Probably conflicts with #81127 but solving the eventual merge conflict should be pretty easy.
2021-02-21Rollup merge of #81300 - ssomers:btree_cleanup_leak_tests, r=Mark-SimulacrumYuki Okushi-217/+337
BTree: share panicky test code & test panic during clear, clone Bases almost all tests of panic on the same, richer definition, and extends it to cloning to test panic during clone. r? ```@Mark-Simulacrum```
2021-02-20Update the bootstrap compilerJoshua Nelson-5/+0
Note this does not change `core::derive` since it was merged after the beta bump.
2021-02-20Add FIXME for safety comments that are invalid when T is a ZSTGiacomo Stevanato-0/+4
2021-02-20Document BinaryHeap unsafe functionsGiacomo Stevanato-49/+113
2021-02-20alloc: Added `as_slice` method to `BinaryHeap` collectionVlad Frolov-0/+23
2021-02-18Stabilize `unsafe_op_in_unsafe_fn` lintLeSeulArtichaut-1/+1
2021-02-17Vec::dedup optimization - panic gracefullySoveu-16/+65
2021-02-16Vec::dedup optimizationSoveu-6/+44
2021-02-16a few more diagnostic itemsAndrea Nall-1/+2
2021-02-15requested/proposed changesAndrea Nall-2/+2
2021-02-15Turn may_have_side_effect into an associated constantTomasz Miąsko-3/+1
The `may_have_side_effect` is an implementation detail of `TrustedRandomAccess` trait. It describes if obtaining an iterator element may have side effects. It is currently implemented as an associated function. Turn `may_have_side_effect` into an associated constant. This makes the value immediately available to the optimizer.
2021-02-15Rollup merge of #82060 - taiki-e:typo, r=m-ou-seJonas Schievink-12/+12
Fix typos in BTreeSet::{first, last} docs map -> set
2021-02-15BTree: move more shared iterator code into navigate.rsStein Somers-98/+67
2021-02-15add diagnostic itemsAndrea Nall-0/+2
Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-14Only define rustc_diagnostic_item format_macro in not(test).Mara Bos-1/+1
2021-02-14Improve suggestion for panic!(format!(..)).Mara Bos-0/+1
2021-02-14Rollup merge of #81919 - ssomers:btree_cleanup_comments, r=Mark-SimulacrumDylan DPC-4/+5
BTreeMap: fix internal comments Salvaged from #81372 r? `@Mark-Simulacrum`
2021-02-14Auto merge of #81956 - ssomers:btree_post_75200, r=Mark-Simulacrumbors-19/+7
BTree: remove outdated traces of coercions The introduction of `marker::ValMut` (#75200) meant iterators no longer see mutable keys but their code still pretends it does. And settle on the majority style `Some(unsafe {…})` over `unsafe { Some(…) }`. r? `@Mark-Simulacrum`