summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2023-05-29Swap out CURRENT_RUSTC_VERSION to 1.71.0Mark Rousskov-1/+1
2023-05-27Rollup merge of #111656 - finnbear:string_leak_unbounded_lifetime, r=AmanieuMatthias Krüger-2/+2
Use an unbounded lifetime in `String::leak`. Using `'a` instead of `'static` is predicted to make the process of making `String` generic over an allocator easier/less of a breaking change. See: - https://github.com/rust-lang/rust/pull/109814#issuecomment-1550164195 - https://github.com/rust-lang/rust/pull/109814#issuecomment-1550250163 ACP: https://github.com/rust-lang/libs-team/issues/109
2023-05-27Auto merge of #111934 - scottmcm:stabilize-hash-one, r=Amanieubors-1/+0
Stabilize `BuildHasher::hash_one` FCP completed in https://github.com/rust-lang/rust/issues/86161#issuecomment-1561125732
2023-05-25Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelixbors-1/+11
Support #[global_allocator] without the allocator shim This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim. Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist. To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors. (Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-24Stabilize `BuildHasher::hash_one`Scott McMurray-1/+0
2023-05-23Rollup merge of #111609 - LegionMammal978:internal-unsafe, r=thomccDylan DPC-4/+5
Mark internal functions and traits unsafe to reflect preconditions No semantics are changed in this PR; I only mark some functions and and a trait `unsafe` which already had implicit preconditions. Although it seems somewhat redundant for `numfmt::Part::Copy` to contain a `&[u8]` instead of a `&str`, given that all of its current consumers ultimately expect valid UTF-8. Is the type also intended to work for byte-slice formatting in the future?
2023-05-22Auto merge of #111634 - marc0246:arc-new-uninit-bloat, r=thomccbors-6/+19
Fix duplicate `arcinner_layout_for_value_layout` calls when using the uninit `Arc` constructors What this fixes is the duplicate calls to `arcinner_layout_for_value_layout` seen here: https://godbolt.org/z/jr5Gxozhj The issue was discovered alongside #111603 but is otherwise unrelated to the duplicate `alloca`s, which remain unsolved. Everything I tried to solve said main issue has failed. As for the duplicate layout calculations, I also tried slapping `#[inline]` and `#[inline(always)]` on everything in sight but the only thing that worked in the end is to dedup the calls by hand.
2023-05-18Rollup merge of #111168 - DaniPopes:arguments-to-string, r=Mark-SimulacrumDylan DPC-0/+9
Specialize ToString implementation for fmt::Arguments Generates far fewer instructions by formatting into a String with `fmt::format` directly instead of going through the `fmt::Display` impl. This change is insta-stable.
2023-05-16Use an unbounded lifetime in String::leak.Finn Bear-2/+2
2023-05-16Rollup merge of #111592 - Nemo157:fix-vec-capacity-examples, r=joshtriplettMatthias Krüger-6/+6
Change Vec examples to not assert exact capacity except where it is guaranteed It was [brought up on discord](https://discord.com/channels/273534239310479360/818964227783262209/1107633959329878077) that the `Vec::into_boxed_slice` example contradicted the `Vec::with_capacity` docs in that the returned `Vec` might have _more_ capacity than requested. So, to reduce confusion change all the `assert_eq!(vec.capacity(), _)` to `assert!(vec.capacity() >= _)`, except in 4 examples that have guaranteed capacities: `Vec::from_raw_parts`, `Vec::from_raw_parts_in`, `Vec::<()>::with_capacity`,`Vec::<(), _>::with_capacity_in`.
2023-05-16Fix duplicate `arcinner_layout_for_value_layout` callsmarc0246-6/+19
2023-05-15Fixed typoBenjamin Atelsek-1/+1
2023-05-15Mark internal functions and traits unsafeLegionMammal978-4/+5
2023-05-15Change Vec examples to not assert exact capacity except where it is guaranteedWim Looman-6/+6
2023-05-11Prevent insta-stable no alloc shim supportbjorn3-1/+11
You will need to add the following as replacement for the old __rust_* definitions when not using the alloc shim. #[no_mangle] static __rust_no_alloc_shim_is_unstable: u8 = 0;
2023-05-09Rollup merge of #97320 - usbalbin:stabilize_const_ptr_read, r=m-ou-seMatthias Krüger-1/+0
Stabilize const_ptr_read Stabilizes const_ptr_read, with tracking issue #80377
2023-05-08Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, ↵bors-16/+16
r=Mark-Simulacrum enable `rust_2018_idioms` lint group for doctests With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests. Resolves #106086 Resolves #99144 Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-07enable `rust_2018_idioms` for doctestsozkanonur-16/+16
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-05Stabilize const_ptr_readbors-1/+0
2023-05-04btree_map: `Cursor{,Mut}::peek_prev` must agreeJubilee Young-2/+21
Our `Cursor::peek_prev` and `CursorMut::peek_prev` must agree on how to behave when they are called on the "null element".
2023-05-03Add the basic `ascii::Char` typeScott McMurray-0/+10
2023-05-04Specialize ToString implementation for fmt::ArgumentsDaniPopes-0/+9
2023-04-30Auto merge of #103406 - Jules-Bertholet:from_clone_slice_to_box, r=dtolnaybors-8/+31
Loosen `From<&[T]> for Box<[T]>` bound to `T: Clone` Also loosens `From<Cow<'_, [T]>> for Box<[T]>`'s bound. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/From.3C.26.5BT.5D.3E.20impls.20consistency)
2023-04-29`cfg`-gate `BoxFromSlice` traitJules Bertholet-0/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-04-29Rollup merge of #110958 - compiler-errors:stdlib-refinement, r=cuviperDylan DPC-17/+65
Make sure that some stdlib method signatures aren't accidental refinements In the process of implementing https://rust-lang.github.io/rfcs/3245-refined-impls.html, I found a bunch of stdlib implementations that accidentally "refined" their method signatures by dropping (unnecessary) bounds. This isn't currently a problem, but may become one if/when method signature refining is stabilized in the future. Shouldn't hurt to make these signatures a bit more accurate anyways. NOTE (just to be clear lol): This does not affect behavior at all, since we don't actually take advantage of refined implementations yet!
2023-04-28Make sure that signatures aren't accidental refinementsMichael Goulet-17/+65
2023-04-28replace version placeholdersPietro Albini-19/+19
2023-04-26Loosen `From<&[T]> for Box<[T]>` bound to T: CloneJules Bertholet-8/+30
2023-04-26Rollup merge of #110419 - jsoref:spelling-library, r=jyn514Matthias Krüger-5/+5
Spelling library Split per https://github.com/rust-lang/rust/pull/110392 I can squash once people are happy w/ the changes. It's really uncommon for large sets of changes to be perfectly acceptable w/o at least some changes. I probably won't have time to respond until tomorrow or the next day
2023-04-26Spelling library/Josh Soref-5/+5
* advance * aligned * borrowed * calculate * debugable * debuggable * declarations * desugaring * documentation * enclave * ignorable * initialized * iterator * kaboom * monomorphization * nonexistent * optimizer * panicking * process * reentrant * rustonomicon * the * uninitialized Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-25Rollup merge of #110796 - madsravn:wake-example, r=Mark-SimulacrumMatthias Krüger-1/+2
Updating Wake example to use new 'pin!' macro Closes: https://github.com/rust-lang/rust/issues/109965 I have already had this reviewed and approved here: https://github.com/rust-lang/rust/pull/110026 . But because I had some git issues and chose the "nuke it" option as my solution it didn't get merged. I nuked it too quickly. I am sorry for trouble of reviewing twice.
2023-04-25Updating Wake example to use new 'pin!' macroMads Ravn-1/+2
2023-04-25Auto merge of #103093 - rytheo:linked-list-alloc-api, r=Mark-Simulacrumbors-135/+224
Add support for allocators in `LinkedList` Allows `LinkedList` to use a custom allocator
2023-04-24Add support for allocators in LinkedListRyan Lowe-135/+224
2023-04-25Revert "Report allocation errors as panics"Matthias Krüger-76/+9
This reverts commit c9a6e41026d7aa27d897fb83e995447719753076.
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-2/+8
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-25Revert "Rename -Zoom=panic to -Zoom=unwind"Matthias Krüger-2/+2
This reverts commit 4b981c26487ebe56de6b3000fcd98713804beefc.
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-17/+78
Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
2023-04-22Rollup merge of #110635 - scottmcm:zst-checks, r=the8472Yuki Okushi-14/+6
More `IS_ZST` in `library` I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways https://github.com/rust-lang/rust/blob/d19b64fb54391b64ce99981577c67c93ac2a9ffa/library/core/src/slice/iter/macros.rs#L76-L93 so started making this PR, then added a few more I found since I was already making changes anyway.
2023-04-21More `IS_ZST` in `library`Scott McMurray-14/+6
I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways https://github.com/rust-lang/rust/blob/d19b64fb54391b64ce99981577c67c93ac2a9ffa/library/core/src/slice/iter/macros.rs#L76-L93 so started making this PR, then added a few more I found since I was already making changes anyway.
2023-04-20More `mem::take` in `library`Scott McMurray-1/+1
A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-20Don't reexport core::fmt::rt from alloc::fmt.Mara Bos-2/+0
2023-04-16Rename -Zoom=panic to -Zoom=unwindAmanieu d'Antras-2/+2
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-8/+2
2023-04-16Report allocation errors as panicsAmanieu d'Antras-9/+76
2023-04-16fix allocDeadbeef-12/+6
2023-04-16core is now compilableDeadbeef-2/+0
2023-04-16rm const traits in libcoreDeadbeef-14/+7
2023-04-14Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitorMatthias Krüger-51/+29
Remove some unneeded imports / qualified paths Continuation of #105537.
2023-04-14Rollup merge of #110292 - scottmcm:sort-features-2, r=jyn514Yuki Okushi-21/+25
Add `tidy-alphabetical` to features in `alloc` & `std` So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often. Follow-up to #110269 cc `@jyn514`