about summary refs log tree commit diff
path: root/library/alloc/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-06-01Use #[rustc_box] in alloc instead of box syntaxest31-1/+2
2022-05-30Add reexport of slice::from{,_mut}_ptr_range to alloc & stdMaybe Waffle-0/+1
At first I was confused why `std::slice::from_ptr_range` didn't work :D
2022-05-27Use `pointer::is_aligned` in ThinBox debug assertThom Chiovoloni-0/+1
2022-05-11Apply CR suggestions; add real tracking issueScott McMurray-1/+1
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-0/+1
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-06Add a dedicated length-prefixing method to `Hasher`Scott McMurray-0/+1
This accomplishes two main goals: - Make it clear who is responsible for prefix-freedom, including how they should do it - Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.
2022-05-02Share testing utilities with non-btree test casesStein Somers-0/+2
2022-04-14library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstableVadim Petrochenkov-0/+2
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-0/+7
2022-04-08Add ThinBox type for 1 stack pointer sized heap allocated trait objectsJane Lusby-0/+2
Relevant commit messages from squashed history in order: Add initial version of ThinBox update test to actually capture failure swap to middle ptr impl based on matthieu-m's design Fix stack overflow in debug impl The previous version would take a `&ThinBox<T>` and deref it once, which resulted in a no-op and the same type, which it would then print causing an endless recursion. I've switched to calling `deref` by name to let method resolution handle deref the correct number of times. I've also updated the Drop impl for good measure since it seemed like it could be falling prey to the same bug, and I'll be adding some tests to verify that the drop is happening correctly. add test to verify drop is behaving add doc examples and remove unnecessary Pointee bounds ThinBox: use NonNull ThinBox: tests for size Apply suggestions from code review Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com> use handle_alloc_error and fix drop signature update niche and size tests add cfg for allocating APIs check null before calculating offset add test for zst and trial usage prevent optimizer induced ub in drop and cleanup metadata gathering account for arbitrary size and alignment metadata Thank you nika and thomcc! Update library/alloc/src/boxed/thin.rs Co-authored-by: Josh Triplett <josh@joshtriplett.org> Update library/alloc/src/boxed/thin.rs Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-04-08Rollup merge of #95579 - Cyborus04:slice_flatten, r=scottmcmDylan DPC-0/+1
Add `<[[T; N]]>::flatten{_mut}` Adds `flatten` to convert `&[[T; N]]` to `&[T]` (and `flatten_mut` for `&mut [[T; N]]` to `&mut [T]`)
2022-04-08add `<[[T; N]]>::flatten`, `<[[T; N]]>::flatten_mut`, and `Vec::<[T; ↵Cyborus04-0/+1
N]>::into_flattened`
2022-04-05trivial cfg(bootstrap) changesPietro Albini-1/+0
2022-03-29fixup feature position in liballocAria Beingessner-1/+1
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-0/+1
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-07Stabilize const_fn_fn_ptr_basics and const_fn_trait_boundEric Holk-1/+1
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+0
2022-02-18Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahcMatthias Krüger-1/+1
Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator` Following amendments in https://github.com/rust-lang/rfcs/pull/3208/. cc #79024 cc ``@yoshuawuyts`` ``@joshtriplett``
2022-02-12Stabilise inherent_ascii_escape (FCP in #77174)ltdk-1/+0
2022-02-09Stabilize cfg_target_has_atomicAmanieu d'Antras-1/+1
Closes #32976
2022-02-05Mark __rgl_oom and __rd_oom as "C-unwind"Amanieu d'Antras-0/+1
2022-02-03Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`.Charles Lew-1/+1
2022-01-28update cfg(bootstrap)sPietro Albini-12/+8
2022-01-11Partially stabilize `maybe_uninit_extra`Miguel Ojeda-1/+0
This covers: impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: https://github.com/rust-lang/rust/issues/63567#issuecomment-958590287. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-04Fix a compile error when no_global_oom_handlingwoppopo-1/+1
2022-01-04Add tracking issues (`const_box`, `const_alloc_error`)woppopo-1/+2
2021-12-23Constify `Box<T, A>` methodswoppopo-0/+15
2021-12-15Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, ↵Matthias Krüger-1/+1
r=jackh726,pnkfelix Stabilize `destructuring_assignment` Closes #71126 - [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058) - [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819) `@rustbot` label +F-destructuring-assignment +T-lang Also needs +relnotes but I don't have permission to add that tag.
2021-12-14Stabilize `destructuring_assignment`Jacob Pratt-1/+1
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-11-30Apply cfg-bootstrap switchMark Rousskov-1/+0
2021-11-15Stabilize format_args_captureJosh Triplett-1/+1
Works as expected, and there are widespread reports of success with it, as well as interest in it.
2021-11-15Give examples of format args capture in the fmt module documentationJosh Triplett-0/+1
2021-11-13Auto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, ↵bors-1/+2
r=joshtriplett Make RawVec private to alloc RawVec was previously exposed for compiler-internal use (libarena specifically) in 1acbb0a9350560d951359cc359361b87992a6f2b Since it is unstable, doc-hidden and has no associated tracking issue it was never meant for public use. And since it is no longer used outside alloc itself it can be made private again. Also remove some functions that are dead due to lack of internal users.
2021-11-05Add feature to `alloc` so we can re-export.mbartlett21-0/+1
2021-11-03Make RawVec private to allocThe8472-1/+2
RawVec was previously exposed for compiler-internal use (libarena specifically) in 1acbb0a9350560d951359cc359361b87992a6f2b Since it is unstable, doc-hidden and has no associated tracking issue it was never meant for public use. And since it is no longer used outside alloc itself it can be made private again. Also remove some functions that are dead due to lack of internal users.
2021-10-31Rollup merge of #89951 - ojeda:stable-unwrap_unchecked, r=dtolnayMatthias Krüger-1/+0
Stabilize `option_result_unwrap_unchecked` Closes https://github.com/rust-lang/rust/issues/81383. Stabilization report: https://github.com/rust-lang/rust/issues/81383#issuecomment-944498212. ```@rustbot``` label +A-option-result +T-libs-api
2021-10-23update cfg(bootstrap)Pietro Albini-1/+1
2021-10-20Stabilize `option_result_unwrap_unchecked`Miguel Ojeda-1/+0
Closes https://github.com/rust-lang/rust/issues/81383. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-10-19Reenable feature(nll) in alloc.Mara Bos-0/+1
2021-10-19Remove unused language #![feature]s from alloc.Mara Bos-5/+0
2021-10-19Remove unused library #![feature]s from alloc.Mara Bos-3/+0
2021-10-19Sort and categorize #![feature]s in alloc.Mara Bos-42/+52
2021-10-15Remove alloc::preludeAmanieu d'Antras-1/+0
As per the libs team decision in #58935. Closes #58935
2021-10-14Fix missing remaining compiler specific cfg informationGuillaume Gomez-0/+1
2021-10-09Cfg hide no_global_oom_handling and no_fp_fmt_parseGary Guo-0/+1
2021-10-08Cfg hide more conditions for allocLoïc BRANSTETT-1/+6
2021-10-06Clean up code a bit:Guillaume Gomez-2/+3
* Remove "bool_to_options" feature * Update version for compiler feature * rustfmt
2021-10-05Suppress some cfg from being shown in the stdlib docsWim Looman-1/+6
2021-09-30implement advance_(back_)_by on more iteratorsThe8472-0/+1