about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2020-04-22More diagnostic items for Clippy usagePhilipp Hansch-0/+2
This adds a couple of more diagnostic items to be used in Clippy. I chose these particular ones because they were the types which we seem to check for the most in Clippy. I'm not sure if the `cfg_attr(not(test))` is needed, but it was also used for `Vec` and a few other types.
2020-04-19Rollup merge of #71107 - vorner:weak-into-raw-dangling, r=AmanieuDylan DPC-54/+80
Address concerns of weak-into-raw This should address the standing concerns in https://github.com/rust-lang/rust/issues/60728#issuecomment-612525616. I've still left the ability to create a new dangling pointer from `null`, as I feel like this is the natural behaviour to expect, but I'm fine removing that too. I've modified the documentation to allow the `as_ptr` or `into_ptr` to return whatever garbage in case of a dangling pointer. I've also removed the guarantee to be able to do `from_raw(as_ptr)` from the documentation (but it would still work right now). I've renamed the method and added implementations for `Rc`/`Arc`. I've also tried if I can just „enable“ unsized types. I believe the current interface is compatible with them. But the inner implementation will be a bit challenging ‒ I can't use the `data_offset` as is used by `Rc` or `Arc` because it AFAIK „touches“ (creates a reference to) the live value of `T` ‒ and in case of `Weak`, it might be completely bogus or already dead ‒ so that would be UB. `./x.py test tidy` is completely mad on my own system all over the code base :-(. I'll just hope it goes through CI, or will fix as necessary. Is it OK if I ask @Amanieu for review, as the concerns are from you? ~r @Amanieu
2020-04-19weak-into-raw: Add {Arc,Rc}::as_ptrMichal 'vorner' Vaner-2/+50
For consistency with Weak
2020-04-19Explain why we shouldn't add inline attr to into_vecYuki Okushi-0/+3
2020-04-18Auto merge of #71204 - JohnTitor:into-vec, r=wesleywiserbors-1/+0
perf: Remove inline attribute from `into_vec()` It was introduced in #70565 and is likely related to this perf results: https://perf.rust-lang.org/compare.html?start=1edcfc83c6a08ddc5e63fc652b149baea0236e7c&end=d249d756374737eb014079901ac132f1e1ed905e&stat=instructions:u Let's check if it's related to that. r? @wesleywiser could you kick off perf check? I don't think I can do it.
2020-04-17Rollup merge of #71167 - RalfJung:big-o, r=shepmasterDylan DPC-34/+33
big-O notation: parenthesis for function calls, explicit multiplication I saw `O(n m log n)` in the docs and found that really hard to parse. In particular, I don't think we should use blank space as syntax for *both* multiplication and function calls, that is just confusing. This PR makes both multiplication and function calls explicit using Rust-like syntax. If you prefer, I can also leave one of them implicit, but I believe explicit is better here. While I was at it I also added backticks consistently.
2020-04-17Implement `Clone` for `liballoc::collections::linked_list::Cursor`.Charles Lew-0/+8
2020-04-17Rollup merge of #71220 - cuviper:std_or_patterns, r=Mark-SimulacrumDylan DPC-6/+2
Dogfood or_patterns in the standard library We can start using `or_patterns` in the standard library as a step toward stabilization. cc #54883 @Centril
2020-04-16Rollup merge of #71219 - JOE1994:patch-4, r=Mark-SimulacrumDylan DPC-6/+6
Minor fixes to doc comments of 'VecDeque' 1. Changed descriptions of `fn get` & `fn get_mut`. Since both of these functions are returning references, and not the owned value, I thought the doc comments could be fixed to be consistent with doc comments of `fn front` & `fn front_mut`. 2. Other changes are minor fixes or additions for clarification. Thank you for taking a look :)
2020-04-16Minor fixes to doc comments of 'VecDequeue'Youngsuk Kim-6/+6
1. Changed descriptions of `fn get` & `fn get_mut`. Since both of these functions are returning references, and not the owned value, I thought the doc comments could be fixed to be consistent with doc comments of `fn front` & `fn front_mut`. 2. Other changes are minor fixes or additions for clarification. Thank you for taking a look :)
2020-04-16Dogfood or_patterns in the standard libraryJosh Stone-6/+2
2020-04-17Remove inline attribute from `into_vec()`Yuki Okushi-1/+0
2020-04-16Implement `Box::into_raw` based on `Box::leak`Simon Sapin-10/+17
… instead of the other way around.
2020-04-15Fix clippy warningsMatthias Krüger-6/+6
clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
2020-04-15Apply suggestions from code reviewSimon Sapin-2/+2
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-04-15don't specify log base in big-ORalf Jung-3/+3
2020-04-15Deprecate `Rc::into_raw_non_null` and `Arc::into_raw_non_null`Simon Sapin-0/+4
2020-04-15Deprecate `Box::into_raw_non_null`Simon Sapin-28/+32
Per https://github.com/rust-lang/rust/issues/47336#issuecomment-586589016
2020-04-15big-O notation: parenthesis, multiplication and backticksRalf Jung-33/+32
2020-04-14Rollup merge of #71133 - MiSawa:fix-sort-by-key-doc, r=Dylan-DPCDylan DPC-1/+1
Tighten time complexity on the doc of sort_by_key Fixes #71132
2020-04-14Rollup merge of #70949 - WaffleLapkin:simlify_vec_macro, r=petrochenkovDylan DPC-3/+2
simplify `vec!` macro Simplify `vec!` macro by replacing 2 following branches: - `($($x:expr),*) => (...)` - `($($x:expr,)*) => (...)` with one: - `($($x:expr),* $(,)?) => (...)` This is a minor change, however, this will make the documentation cleaner
2020-04-14Vec drop and truncate: drop using raw slice *mut [T]Ulrik Sverdrup-2/+2
By creating a *mut [T] directly (without going through &mut [T]), avoid questions of validity of the contents of the slice. Consider the following risky code: ```rust unsafe { let mut v = Vec::<bool>::with_capacity(16); v.set_len(16); } ``` The intention is that with this change, the above snippet will be sound because Vec::drop does no longer produces a mutable slice of the vector's contents.
2020-04-14Tighten time complexity on the docmi_sawa-1/+1
2020-04-14Rollup merge of #71121 - AnthonyMikh:fix_string_doc_link, r=Dylan-DPCDylan DPC-0/+1
Fix broken link in documentation for String::from_utf8
2020-04-14Fix broken link in documentation for String::from_utf8AnthonyMikh-0/+1
2020-04-14make `vec![,]` uncompilableWaffle-2/+2
Fix regression introduced in commit #3ae2d21
2020-04-13weak-into-raw: as_raw -> as_ptr + dangling garbageMichal 'vorner' Vaner-52/+30
* Rename Weak::as_raw to Weak::as_ptr for consistency with some other types. * The as_ptr for a dangling Weak pointer might return whatever garbage (and takes that advantage to avoid a conditional). * Don't guarantee to be able to do `Weak::from_raw(weak.as_ptr())` (even though it'll still work fine).
2020-04-13Add examples to Pattern docsIvan Tham-0/+6
2020-04-13Add period to Pattern docsIvan Tham-1/+1
2020-04-11Rollup merge of #70996 - ChaiTRex:master, r=AmanieuDylan DPC-0/+28
Add or_insert_with_key to Entry of HashMap/BTreeMap Going along with `or_insert_with`, `or_insert_with_key` provides the `Entry`'s key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time. This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda. --- I'm fairly new to Rust, so any optimizations, corrections to types, better names, better documentation, or whatever else would be appreciated. I'd like to thank Arnavion on freenode for helping me to implement a very similar method when I found that `or_insert_with_key` was unavailable. As a somewhat-related note, this implements https://github.com/rust-lang/rfcs/issues/1202 from 2015, so if this pull request is accepted, that should be closed.
2020-04-11Change issue number to point to tracking issueChai T. Rex-1/+1
2020-04-10Fixed doc tests for added methodsChai T. Rex-0/+1
2020-04-10Add or_insert_with_key to Entry of HashMap/BTreeMapChai T. Rex-0/+27
Going along with or_insert_with, or_insert_with_key provides the Entry's key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time. This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.
2020-04-10Rollup merge of #70981 - ssomers:btreemap_into_into_iter, r=Mark-SimulacrumMazdak Farrokhzad-13/+13
Rearrange BTreeMap::into_iter to match range_mut. r? @Mark-Simulacrum I wondered why you catered for the optional root differently in `into_iter` than in `range_mut`.
2020-04-10Rollup merge of #70979 - ssomers:btreemap_the_alice_merton_variations, r=AmanieuMazdak Farrokhzad-4/+2
Follow up on BTreeMap comments r? @Amanieu (for the first commit)
2020-04-10Rollup merge of #70913 - eddyb:rc-arc-diagnostic-items, r=matthewjasperMazdak Farrokhzad-2/+4
Replace "rc"/"arc" lang items with Rc/Arc diagnostic items. `Rc`/`Arc` should have no special semantics, so it seems appropriate for them to not be lang items. r? @matthewjasper
2020-04-10Rollup merge of #70843 - ssomers:btree_drain_filter_epilogue, r=AmanieuMazdak Farrokhzad-45/+21
Remove the Ord bound that was plaguing drain_filter Now that #70795 made it superfluous. Also removes superfluous lifetime specifiers (at least I think they are).
2020-04-10Rearrange BTreeMap::into_iter to match range_mut.Stein Somers-13/+13
2020-04-09Respect the comment: no root unless the borrow type is `Mut`Stein Somers-2/+2
2020-04-09Kill comment left behind by a last minute change in #70795Stein Somers-2/+0
2020-04-09Rollup merge of #70958 - Amanieu:android_try_reserve, r=Mark-SimulacrumMazdak Farrokhzad-0/+6
Disable try_reserve tests on Android Calling `realloc` with large sizes seems to be broken on older Android versions that use dlmalloc as the default allocator. This is not an issue for modern Android versions that use jemalloc. Fixes #55861
2020-04-09Disable try_reserve tests on AndroidAmanieu d'Antras-0/+6
2020-04-09simplify `vec!` macroWaffle-2/+1
Simplify `vec!` macro by replacing 2 following branches: - `($($x:expr),*) => (...)` - `($($x:expr,)*) => (...)` with one: - `($($x:expr),* $(,)?) => (...)`
2020-04-08Rollup merge of #70930 - lcnr:patch-1, r=Dylan-DPCDylan DPC-1/+1
add tracking issue to `VecDeque::make_contiguous` The tracking issue is https://github.com/rust-lang/rust/issues/70929
2020-04-08Rollup merge of #70565 - Zoxc:inlines-query-system, r=davidtwcoDylan DPC-0/+1
Add inline attributes for functions used in the query system
2020-04-08Rollup merge of #70850 - ssomers:btreemap_first_last, r=AmanieuDylan DPC-48/+76
BTreeMap first last proposal tweaks Clean-up and following up on a request in #62924. Trying the reviewer of the original code #65637... r? @scottmcm
2020-04-08add `VecDeque::make_contiguous` tracking issueBastian Kauschke-1/+1
2020-04-08Replace "rc"/"arc" lang items with Rc/Arc diagnostic items.Eduard-Mihai Burtescu-2/+4
2020-04-07Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnayDylan DPC-4/+4
Don't import integer and float modules, use assoc consts 2 Follow up to #70777. I missed quite a lot of places. Partially because I wanted to keep the size of the last PR down, and partially because my regexes were not good enough :) r? @dtolnay
2020-04-06Use split_at in slice's ToOwned::clone_intoJosh Stone-6/+6
It appears to codegen slightly more efficiently with `split_at` taking two slices at once, rather than slicing across different calls.