summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2020-06-20Update stability attribute of new Vec PartialEq implsDavid Tolnay-13/+13
2020-06-20impl PartialEq<Vec<B>> for &[A], &mut [A]Solomon Ucko-0/+59
2020-06-20Satisfy tidyOliver Scherer-1/+1
2020-06-20Remove uses of `Vec::remove_item`Lukas Kalbertodt-16/+0
2020-06-20Deprecate `Vec::remove_item`Lukas Kalbertodt-10/+8
2020-06-20Add liballoc impl SpecFromElem for i8Ivan Tham-1/+15
Speedup vec![1_i8; N] for non-zero element. Before test do_bench_from_elem_i8 ... bench: 130 ns/iter (+/- 7) = 61 MB/s test do_bench_from_elem_u8 ... bench: 121 ns/iter (+/- 4) = 66 MB/s After test do_bench_from_elem_i8 ... bench: 123 ns/iter (+/- 7) = 65 MB/s test do_bench_from_elem_u8 ... bench: 121 ns/iter (+/- 5) = 66 MB/s No speed difference if element is already zero. #[bench] fn do_bench_from_elem_i8(b: &mut Bencher) { b.bytes = 8 as u64; b.iter(|| { let dst = ve::vec![10_i8; 100]; assert_eq!(dst.len(), 100); assert!(dst.iter().all(|x| *x == 10)); }) } As suggested by @cuviper https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/SpecForElem.20for.20other.20integers
2020-06-19Rollup merge of #73465 - lzutao:spec-char-tostring, r=sfacklerManish Goregaokar-0/+8
Add specialization of `ToString for char` Closes #73462
2020-06-19Rollup merge of #72709 - LeSeulArtichaut:unsafe-liballoc, r=nikomatsakisManish Goregaokar-257/+387
`#[deny(unsafe_op_in_unsafe_fn)]` in liballoc This PR proposes to make use of the new `unsafe_op_in_unsafe_fn` lint, i.e. no longer consider the body of an unsafe function as an unsafe block and require explicit unsafe block to perform unsafe operations. This has been first (partly) suggested by @Mark-Simulacrum in https://github.com/rust-lang/rust/pull/69245#issuecomment-587817065 Tracking issue for the feature: #71668. ~~Blocked on #71862.~~ r? @Mark-Simulacrum cc @nikomatsakis can you confirm that those changes are desirable? Should I restrict it to only BTree for the moment?
2020-06-19Apply suggestions from code reviewLeSeulArtichaut-9/+11
Co-authored-by: nikomatsakis <niko@alum.mit.edu>
2020-06-19`#[deny(unsafe_op_in_unsafe_fn)]` in liballocLeSeulArtichaut-261/+389
2020-06-19Rollup merge of #73479 - pickfire:liballoc-spell, r=dtolnayRalf Jung-3/+3
Minor tweaks to liballoc
2020-06-19Rollup merge of #73459 - cuviper:into_boxed_slice-unicast, r=dtolnayRalf Jung-1/+1
Reduce pointer casts in Box::into_boxed_slice We only need to cast the pointer once to change `Box<T>` to an array `Box<[T; 1]>`, then we can let unsized coercion return `Box<[T]>`.
2020-06-19Rearrange liballoc __impl_slice_eq1Ivan Tham-1/+1
2020-06-19Liballoc clean up macro_rules styleIvan Tham-1/+1
2020-06-19Fix liballoc doc spellingIvan Tham-1/+1
2020-06-18Ensure std benchmarks get tested.Eric Huss-0/+1
2020-06-18add test for char into stringMatthias Krüger-0/+7
2020-06-18impl From<char> for StringMatthias Krüger-0/+8
This allows us to write fn char_to_string() -> String { 'a'.into() } which was not possible before.
2020-06-18Add specialization of `ToString for char`Lzu Tao-0/+8
2020-06-17Reduce pointer casts in Box::into_boxed_sliceJosh Stone-1/+1
We only need to cast the pointer once to change `Box<T>` to an array `Box<[T; 1]>`, then we can let unsized coercion return `Box<[T]>`.
2020-06-15Rollup merge of #72584 - CAD97:stabilize-58957, r=dtolnayRalf Jung-2/+8
Stabilize vec::Drain::as_slice and add `AsRef<[T]> for Drain<'_, T>`. Tracking issue: #58957. Does not stabilize `slice::IterMut::as_slice` yet. cc @cuviper This PR proposes stabilizing just the `vec::Drain::as_slice` part of that tracking issue. My ultimate goal here: being able to use `for<T, I: Iterator<Item=T> + AsRef<[T]>> I` to refer to `vec::IntoIter`, `vec::Drain`, and eventually `array::IntoIter`, as an approximation of the set of by-value iterators that can be "previewed" as by-ref iterators. (Actually expressing that as a trait requires GAT.)
2020-06-12Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnayDylan DPC-17/+17
Migrate to numeric associated consts The deprecation PR is #72885 cc #68490 cc rust-lang/rfcs#2700
2020-06-10Migrate to numeric associated constsLzu Tao-17/+17
2020-06-09Rename some identifiers in `RawVec` and `libarena`.Nicholas Nethercote-53/+36
- Use `len` more consistently for the number of elements in a vector, because that's the usual name. - Use `additional` more consistently for the number of elements we want to add, because that's what `Vec::reserve()` uses. - Use `cap` consistently rather than `capacity`. - Plus a few other tweaks. This increases consistency and conciseness.
2020-06-09Remove `RawVec::reserve_in_place`.Nicholas Nethercote-39/+6
Also remove a now-unnecessary `placement` argument.
2020-06-08Rollup merge of #72811 - pickfire:liballoc-impl, r=AmanieuRalf Jung-42/+40
Liballoc impl Mainly code rearrangements
2020-06-08Rollup merge of #72583 - CAD97:vec-iter-asref-slice, r=dtolnayRalf Jung-0/+7
impl AsRef<[T]> for vec::IntoIter<T> Adds `impl<T> AsRef<[T]> for vec::IntoIter<T>`. This mirrors the same trait impl for [`slice::Iter`](https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html). Both types already offer `fn as_slice(&self) -> &[T]`, this just adds the trait impl for `vec::IntoIter`. If/when `fn as_slice(&self) -> &[T]` stabilizes for `vec::Drain` and `slice::IterMut`, they should get `AsRef<[T]>` impls as well. As thus, tangentially related to #58957. My ultimate goal here: being able to use `for<T, I: Iterator<Item=T> + AsRef<[T]>> I` to refer to `vec::IntoIter`, `vec::Drain`, and eventually `array::IntoIter`, as an approximation of the set of by-value iterators that can be "previewed" as by-ref iterators. (Actually expressing that as a trait requires GAT.)
2020-06-06Elide type on liballoc vecIvan Tham-1/+1
2020-06-05Auto merge of #73025 - Dylan-DPC:rollup-a1uzj5u, r=Dylan-DPCbors-1/+1
Rollup of 5 pull requests Successful merges: - #72260 (Spell out `Self` in async function return) - #72996 (Remove unsused `NodeId` related APIs in hir map) - #73010 (Update RELEASES.md) - #73017 (Use assert_eq for liballoc test) - #73019 (add test for #72960) Failed merges: r? @ghost
2020-06-05Auto merge of #72957 - Mark-Simulacrum:bootstrap-bump, r=sfacklerbors-24/+5
Bump bootstrap compiler to 1.45 Pretty standard update.
2020-06-05Use assert_eq for liballoc testIvan Tham-1/+1
2020-06-05Add more assert to Vec with_capacity docsIvan Tham-0/+3
Show assertion on len too to show them how adding new items will affect both the length and capacity, before and after.
2020-06-03Bump to 1.46Mark Rousskov-24/+5
2020-06-03Add assert to Vec with_capacity docsIvan Tham-0/+2
2020-06-01Mention that BTreeMap::new() doesn't allocateTrolledWoods-0/+2
I think it would be nice to mention this, so you don't have to dig through the src to look at the definition of new().
2020-05-31Merge raw_vec into_box with previous impl<T, Global>Ivan Tham-26/+24
There are two separate `impl<T, Global>` which no special reason, it would be better to merge both of them.
2020-05-31Rearrange impl blocks with Deref as firstIvan Tham-16/+16
The other blocks depends on Deref to make it easier for readers when reimplementing or reading the implementations.
2020-05-30Rollup merge of #72499 - mendess:master, r=dtolnayRalf Jung-0/+41
Override Box::<[T]>::clone_from Avoid dropping and reallocating when cloning to an existing box if the lengths are the same. It would be nice if this could also be specialized for `Copy` but I don't know how that works since it's not on stable. Will gladly look into it if it's deemed as a good idea. This is my first PR with code, hope I did everything right :smile:
2020-05-30Rollup merge of #72162 - cuviper:extend_one, r=Mark-SimulacrumYuki Okushi-0/+126
Add Extend::{extend_one,extend_reserve} This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+126
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-29Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJungbors-0/+19
Rollup of 9 pull requests Successful merges: - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes) - #71095 (impl From<[T; N]> for Box<[T]>) - #71500 (Make pointer offset methods/intrinsics const) - #71804 (linker: Support `-static-pie` and `-static -shared`) - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn) - #72103 (borrowck `DefId` -> `LocalDefId`) - #72407 (Various minor improvements to Ipv6Addr::Display) - #72413 (impl Step for char (make Range*<char> iterable)) - #72439 (NVPTX support for new asm!) Failed merges: r? @ghost
2020-05-29Rollup merge of #71095 - pickfire:box-from-array, r=dtolnayRalf Jung-0/+19
impl From<[T; N]> for Box<[T]> Based on https://github.com/rust-lang/rust/pull/68692
2020-05-29Rollup merge of #72701 - pickfire:patch-1, r=Mark-SimulacrumDylan DPC-1/+1
Fix grammar in liballoc raw_vec
2020-05-29Remove flaky test and document the other's flakinessmendess-8/+5
2020-05-29Rollup merge of #72288 - vorner:stabilize-weak-into-raw, r=dtolnayYuki Okushi-24/+8
Stabilization of weak-into-raw Closes #60728. There are also two removals of `#![feature(weak_into_raw)]` in the `src/tools/miri` submodule. How should I synchronize the changes with there? * I can ignore it for now and once this gets merged, update the tool, send a pull request to that one and then reference the changes to rustc. * I could try submitting the changes to miri first, but then the build would fail there, because the attribute would still be needed. I think the first one is the correct one, extrapolating from the contributing guidelines (even though they speak about breaking the tools and this should not break it, as extra feature should not hurt).
2020-05-29Fix grammar in liballoc raw_vecIvan Tham-1/+1
2020-05-27added .collect() into String from Box<str> with fake feature/stability ↵djugei-0/+16
annotation
2020-05-27Rollup merge of #72533 - Diggsey:db-fix-arc-ub2, r=dtolnayDylan DPC-9/+26
Resolve UB in Arc/Weak interaction (2) Use raw pointers to avoid making any assertions about the data field. Follow up from #72479, see that PR for more detail on the motivation. @RalfJung I was able to avoid a lot of the changes to `Weak`, by making a helper type (`WeakInner`) - because of auto-deref and because the fields have the same name, the rest of the code continues to compile.
2020-05-25stabilize vec_drain_as_sliceCAD97-2/+8
2020-05-25impl AsRef<[T]> for vec::IntoIter<T>CAD97-0/+7