about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2025-08-26Fix typo in commentTobias Stoeckmann-1/+1
Turn "any heap allocators" into "any heap allocator".
2025-08-26Rollup merge of #144373 - hkBst:remove-deprecated-1, r=jhprattGuillaume Gomez-51/+5
remove deprecated Error::description in impls [libs-api permission](https://github.com/rust-lang/libs-team/issues/615#issuecomment-3074045829) r? `@cuviper` or `@jhpratt`
2025-08-26remove deprecated Error::description in implsMarijn Schouten-51/+5
2025-08-24Prevent confusion with insertion-ordered maps.Marijn Schouten-2/+3
2025-08-24focus more on ordered aspect and restore old commentsMarijn Schouten-13/+45
2025-08-24Dial down detail of B-tree descriptionMarijn Schouten-24/+5
fixes 134088, though it is a shame to lose some of this wonderful detail.
2025-08-20Diff-massaging commitltdk-41/+34
2025-08-20Move WTF-8 code from std to core/allocltdk-708/+178
2025-08-20Copy WTF-8 code into core/alloc (for better diffs)ltdk-0/+1834
2025-08-20Auto merge of #144086 - clubby789:alloc-zeroed, r=nikicbors-0/+1
Pass `alloc-variant-zeroed` to LLVM Makes use of https://github.com/llvm/llvm-project/pull/138299 (once we pull in a version of LLVM with this attribute). ~~Unfortunately also requires https://github.com/llvm/llvm-project/pull/149336 to work.~~ Closes rust-lang/rust#104847
2025-08-20Pass `alloc-variant-zeroed` to LLVMclubby789-0/+1
2025-08-19Use `ToString` specialization macro also for `Cow` and `String`Tobias Bucher-16/+2
2025-08-19Simplify macro generating `ToString` implementations for `&…&str`Tobias Bucher-34/+21
Use deref coercion to let the compiler remove any amount of references.
2025-08-15Rollup merge of #143717 - Jules-Bertholet:pin-default, r=dtolnayJacob Pratt-4/+44
Add `Default` impls for `Pin`ned `Box`, `Rc`, `Arc` Fixes rust-lang/rust#143688. `@rustbot` label T-libs-api needs-fcp Also needs a crater run, as the `Box` impls could theoretically be breaking due to `#[fundamental]` (though a [cursory search](https://github.com/search?q=%2Fimpl%28%3C.*%3E%29%3F+Default+for+Pin%3C%2F+path%3A*.rs&type=code) suggests this is unlikely to cause issues).
2025-08-12Add cast_init and cast_uninit methods for pointersltdk-1/+2
2025-08-12Handle the `capacity == 0` caseSabrinaJewson-27/+34
2025-08-11Respond to review commentsSabrinaJewson-5/+5
2025-08-11Make explicit guarantees about `Vec`’s allocatorSabrinaJewson-4/+47
This commit amends the documentation of `Vec::as_mut_ptr` and `Vec::into_raw_parts` to make it explicit that such calls may be paired with calls to `dealloc` with a suitable layout. This guarantee was effectively already provided by the docs of `Vec::from_raw_parts` mentioning `alloc`. Additionally, we copy-paste and adjust the “Memory layout” section from the documentation of `std::boxed` to `std::vec`. This explains the allocator guarantees in more detail.
2025-08-09`{BTree,Hash}Map`: add "`Entry` API" section headingAda Alakbarova-0/+2
2025-08-07Auto merge of #144997 - BoxyUwU:bootstrap_bump, r=Mark-Simulacrumbors-8/+8
bump bootstrap compiler to 1.90 beta There were significantly less `cfg(bootstrap)` and `cfg(not(bootstrap))` this release. Presumably due to the fact that we change the bootstrap stage orderings to reduce the need for them and it was successful :pray:
2025-08-06replace version placeholderBoxy-8/+8
2025-08-04Correct the use of `must_use` on btree::IterMutJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-04remove gatesKivooeo-4/+2
2025-08-02Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=AmanieuSamuel Tardieu-7/+7
Improve formatting of doc code blocks We don't currently apply automatic formatting to doc comment code blocks. As a result, it has built up various idiosyncracies, which make such automatic formatting difficult. Some of those idiosyncracies also make things harder for human readers or other tools. This PR makes a few improvements to doc code formatting, in the hopes of making future automatic formatting easier, as well as in many cases providing net readability improvements. I would suggest reading each commit separately, as each commit contains one class of changes.
2025-07-31Rollup merge of #135975 - balt-dev:master, r=tgross35Stuart Cook-29/+243
Implement `push_mut` Implementation of rust-lang/rust#135974.
2025-07-30Implement push_mutBalt-29/+243
2025-07-27Remove `[T]::array_chunks(_mut)`Scott McMurray-17/+12
2025-07-25Avoid placing `// FIXME` comments inside doc code blocksJosh Triplett-6/+6
This leads tools like rustfmt to get confused, because the doc code block effectively spans two doc comments. As a result, the tools think the first code block is unclosed, and the subsequent terminator opens a new block. Move the FIXME comments outside the doc code blocks, instead.
2025-07-25Improve and regularize comment placement in doc codeJosh Triplett-1/+1
Because doc code does not get automatically formatted, some doc code has creative placements of comments that automatic formatting can't handle. Reformat those comments to make the resulting code support standard Rust formatting without breaking; this is generally an improvement to readability as well. Some comments are not indented to the prevailing indent, and are instead aligned under some bit of code. Indent them to the prevailing indent, and put spaces *inside* the comments to align them with code. Some comments span several lines of code (which aren't the line the comment is about) and expect alignment. Reformat them into one comment not broken up by unrelated intervening code. Some comments are placed on the same line as an opening brace, placing them effectively inside the subsequent block, such that formatting would typically format them like a line of that block. Move those comments to attach them to what they apply to. Some comments are placed on the same line as a one-line braced block, effectively attaching them to the closing brace, even though they're about the code inside the block. Reformat to make sure the comment will stay on the same line as the code it's commenting.
2025-07-22Rename `tests/codegen` into `tests/codegen-llvm`Guillaume Gomez-2/+2
2025-07-19Stabilize `new_zeroed_alloc`Thalia Archibald-40/+6
2025-07-18Rollup merge of #143909 - nik-rev:patch-1, r=jhprattMatthias Krüger-2/+2
docs(alloc::fmt): Make type optional, instead of matching empty string Think this is clearer. Noticed as I was implementing [`tree-sitter-rust-format-args`](https://github.com/nik-rev/tree-sitter-rust-format-args), and attempting to match the empty string results in an error.
2025-07-17Rollup merge of #143595 - fee1-dead-contrib:push-sylpykzkmynr, ↵León Orell Valerian Liehr-3/+4
r=RalfJung,fee1-dead add `const_make_global`; err for `const_allocate` ptrs if didn't call Implements as discussed on Zulip: [#t-compiler/const-eval > const heap](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const.20heap/with/527125421) r? ```@rust-lang/wg-const-eval``` Fixes https://github.com/rust-lang/rust/issues/129233
2025-07-15Add `Default` impls for `Pin`ned `Box`, `Rc`, `Arc`Jules Bertholet-4/+44
2025-07-16add `const_make_global`; err for `const_allocate` ptrs if didn't callDeadbeef-3/+4
Co-Authored-By: Ralf Jung <post@ralfj.de> Co-Authored-By: Oli Scherer <github333195615777966@oli-obk.de>
2025-07-15Auto merge of #143877 - xizheyin:143813, r=scottmcm,saethlinbors-3/+18
`std::vec`: Add UB check for `set_len`, `from_raw_parts_in`, and etc. Closes rust-lang/rust#143813 I noticed that `from_parts_in` do the similar things like `from_raw_parts_in`, so I add the UB check in the last commit. If it is not appropriate, I will remove it. And I fix a typo in the first commit. r? `@scottmcm`
2025-07-13docs(alloc::fmt): Make `type` optional, instead of matching the empty stringNik Revenco-2/+2
2025-07-13update issue number for `const_trait_impl`Deadbeef-2/+2
2025-07-13std::vec: Add UB check in `from_parts_in`xizheyin-0/+5
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13std::vec: Add UB check in `from_raw_parts_in`xizheyin-0/+5
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13`std::vec`: Upgrade `debug_assert` to UB check in `set_len`xizheyin-2/+7
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13Fix typo in `std::vec`xizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-08Auto merge of #134628 - estebank:const-default, r=oli-obkbors-2/+6
Make `Default` const and add some `const Default` impls Full list of `impl const Default` types: - () - bool - char - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
2025-07-08Rollup merge of #143608 - codexarafat:fix-string-doc, r=NoratriebMatthias Krüger-1/+1
Fix in std::String docs This PR removes the word “else” from the sentence ('something else similar') in the String documentation to improve clarity. Fixes rust-lang/rust#143579.
2025-07-08Rollup merge of #142098 - GuillaumeGomez:int_format_into, r=AmanieuMatthias Krüger-2/+4
Implement `int_format_into` feature I took over rust-lang/rust#138338 with `@madhav-madhusoodanan's` approval. Since https://github.com/rust-lang/rust/pull/136264, a lot of changes happened so I made use of them to reduce the number of changes. ACP approval: https://github.com/rust-lang/libs-team/issues/546#issuecomment-2707244569 ## Associated Issue - https://github.com/rust-lang/rust/issues/138215 r? `@hanna-kruppe`
2025-07-07Make `Default` const and add some `const Default` implsEsteban Küber-2/+6
Full list of `impl const Default` types: - () - bool - char - Cell - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
2025-07-08Fix in String docs: remove 'else' from 'something else similar'Md. Yeasin Arafat-1/+1
2025-07-06Renamed retain_mut to retain on LinkedList as mentioned in the ACPJoshua Gentry-37/+2
2025-07-04Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3Matthias Krüger-2/+2
Make __rust_alloc_error_handler_should_panic a function Fixes rust-lang/rust#143253 `__rust_alloc_error_handler_should_panic` is a static but was being exported as a function. For most targets this doesn't matter, but Arm64EC Windows uses different decorations for exported variables vs functions, hence it fails to link when `-Z oom=abort` is enabled. We've had issues in the past with statics like this (see rust-lang/rust#141061) but the tldr; is that Arm64EC needs symbols correctly exported as either a function or data, and data MUST and MUST ONLY be marked `dllimport` when the symbol is being imported from another binary, which is non-trivial to calculate for these compiler-generated statics. So, instead, the easiest thing to do is to make `__rust_alloc_error_handler_should_panic` a function instead. Since `__rust_alloc_error_handler_should_panic` isn't involved in any linking shenanigans, I've marked it as `AlwaysInline` with the hopes that the various backends will see that it is just returning a constant and perform the same optimizations as the previous implementation. r? `@bjorn3`
2025-07-03Remove PointerLike traitMichael Goulet-5/+1