about summary refs log tree commit diff
path: root/library/alloc/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-09-27Remove `cfg(bootstrap)` for `doc_cfg` feature following #141925Guillaume Gomez-16/+1
2025-09-27fmtGuillaume Gomez-6/+1
2025-09-27Remove `doc_cfg_hide` featureGuillaume Gomez-1/+1
2025-09-27Strenghten checks for `doc(auto_cfg(show/hide))` attributesGuillaume Gomez-1/+0
2025-09-27Implement RFC 3631Guillaume Gomez-8/+21
2025-09-01Constify conversion traitsltdk-1/+2
2025-08-20Move WTF-8 code from std to core/allocltdk-0/+3
2025-08-12Add cast_init and cast_uninit methods for pointersltdk-0/+1
2025-07-27Remove `[T]::array_chunks(_mut)`Scott McMurray-1/+0
2025-07-15Auto merge of #143877 - xizheyin:143813, r=scottmcm,saethlinbors-0/+1
`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-13`std::vec`: Upgrade `debug_assert` to UB check in `set_len`xizheyin-0/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07Make `Default` const and add some `const Default` implsEsteban Küber-0/+2
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-03Remove PointerLike traitMichael Goulet-1/+0
2025-06-09stabilize nonnull_provenanceRalf Jung-1/+0
2025-06-02Remove more library bootstrapJosh Stone-1/+0
2025-04-27use generic Atomic type where possibleChristopher Durham-0/+1
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-09Speed up `String::push` and `String::insert`lincot-0/+1
Improve performance of `String` methods by avoiding unnecessary memcpy for the character bytes, with added codegen check to ensure compliance.
2025-03-26Pass `Alignment` for `RawVecInner::new_in`James Wainwright-0/+1
Encodes the safety constraint that `Unique`'s pointer must be non-zero into the API.
2025-03-08Rollup merge of #136642 - bjorn3:separate_alloctest_crate, r=cuviperJacob Pratt-37/+2
Put the alloc unit tests in a separate alloctests package Same rationale as https://github.com/rust-lang/rust/pull/135937. This PR has some extra complexity though as a decent amount of tests are testing internal implementation details rather than the public api. As such I opted to include the modules containing the types under test using `#[path]` into the alloctests package. This means that those modules still need `#[cfg(test)]`, but the rest of liballoc no longer need it.
2025-03-07Fully test the alloc crate through alloctestsbjorn3-37/+2
For the tests that make use of internal implementation details, we include the module to test using #[path] in alloctests now.
2025-03-06Add allow(incomplete_features) to allocSantiago Pastorino-0/+1
2025-03-06Add UseCloned trait related codeSantiago Pastorino-0/+1
2025-03-01stabilize `box_uninit_write`Slanterns-1/+0
2025-02-23Rollup merge of #137121 - bend-n:master, r=NoratriebMatthias Krüger-1/+0
stabilize `(const_)ptr_sub_ptr` Tracking issue: #95892 Closes #95892 FCP Completed: https://github.com/rust-lang/rust/issues/95892#issuecomment-2561139730 r? ````@Noratrieb````
2025-02-19Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-seMatthias Krüger-0/+1
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
2025-02-17stabilize (const_)ptr_sub_ptrbendn-1/+0
2025-02-16add MAX_LEN_UTF8 and MAX_LEN_UTF16 constantsHTGAzureX1212-0/+1
2025-02-09Rollup merge of #135488 - GrigorenkoPV:vec_pop_if, r=jhprattMatthias Krüger-1/+0
Stabilize `vec_pop_if` Tracking issue: #122741 FCP completed in https://github.com/rust-lang/rust/issues/122741#issuecomment-2605116387
2025-01-28Rollup merge of #135367 - Urgau:unreach_pub-std-3, r=NoratriebMatthias Krüger-1/+2
Enable `unreachable_pub` lint in `alloc` This PR enables the [`unreachable_pub`](https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unreachable-pub) lint as warn in the `alloc` crate. Most of changes are in the btree implementation and in tests. *The diff was mostly generated with `./x.py fix --stage 1 library/alloc/ -- --broken-code`, as well as manual edits for code in macros and in tests.* Continuation of #134286 and #135366 r? libs
2025-01-25Stabilize `vec_pop_if`Pavel Grigorenko-1/+0
2025-01-23Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushiMatthias Krüger-0/+4
Implement `ByteStr` and `ByteString` types Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (`@BurntSushi).` r? `@BurntSushi`
2025-01-20alloc: add `#![warn(unreachable_pub)]`Urgau-1/+2
2025-01-11Rollup merge of #135347 - samueltardieu:push-qvyxtxsqyxyr, r=jhprattJacob Pratt-0/+1
Use `NonNull::without_provenance` within the standard library This API removes the need for several `unsafe` blocks, and leads to clearer code. It uses feature `nonnull_provenance` (#135243). Close #135343
2025-01-11Implement `ByteStr` and `ByteString` typesJosh Triplett-0/+4
Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, `Borrow`, `From`, and `PartialOrd`, when those would be the second implementation for a type (counting the `T` impl) or otherwise may cause inference failures. These impls are important, but we can attempt to add them later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (@BurntSushi).
2025-01-10Use `NonNull::without_provenance` within the standard librarySamuel Tardieu-0/+1
This API removes the need for several `unsafe` blocks, and leads to clearer code.
2025-01-09Update a bunch of library types for MCP807Scott McMurray-0/+1
This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3: ``` library/core\src\ptr\non_null.rs 68:#[rustc_layout_scalar_valid_range_start(1)] library/core\src\num\niche_types.rs 19: #[rustc_layout_scalar_valid_range_start($low)] 20: #[rustc_layout_scalar_valid_range_end($high)] ``` Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
2025-01-08update cfg(bootstrap)Pietro Albini-1/+0
2025-01-03turn rustc_box into an intrinsicRalf Jung-0/+1
2024-12-13Stabilize async closuresMichael Goulet-1/+1
2024-12-12Rollup merge of #133859 - bjorn3:move_tests_to_alloctests, r=tgross35Matthias Krüger-2/+0
Move some alloc tests to the alloctests crate Unit tests directly inside of standard library crates require a very fragile way of building that is hard to reproduce outside of bootstrap.
2024-12-05Added struct `fmt::FormattingOptions`Elias Holzmann-0/+1
This allows to build custom `std::Formatter`s at runtime. Also added some related enums and two related methods on `std::Formatter`.
2024-12-04Move some alloc tests to the alloctests cratebjorn3-2/+0
Unit tests directly inside of standard library crates require a very fragile way of building that is hard to reproduce outside of bootstrap.
2024-11-30remove a whole bunch of unnecessary const feature gatesRalf Jung-8/+0
2024-11-27update cfgsBoxy-2/+1
2024-11-20Make PointerLike opt-in as a traitMichael Goulet-0/+1
2024-11-19Rollup merge of #123947 - zopsicle:vec_deque-Iter-as_slices, r=AmanieuMatthias Krüger-0/+1
Add vec_deque::Iter::as_slices and friends Add the following methods, that work similarly to VecDeque::as_slices: - alloc::collections::vec_deque::Iter::as_slices - alloc::collections::vec_deque::IterMut::into_slices - alloc::collections::vec_deque::IterMut::as_slices - alloc::collections::vec_deque::IterMut::as_mut_slices Obtaining slices from a VecDeque iterator was not previously possible.
2024-10-22Rename Receiver -> LegacyReceiverAdrian Taylor-1/+1
As part of the "arbitrary self types v2" project, we are going to replace the current `Receiver` trait with a new mechanism based on a new, different `Receiver` trait. This PR renames the old trait to get it out the way. Naming is hard. Options considered included: * HardCodedReceiver (because it should only be used for things in the standard library, and hence is sort-of hard coded) * LegacyReceiver * TargetLessReceiver * OldReceiver These are all bad names, but fortunately this will be temporary. Assuming the new mechanism proceeds to stabilization as intended, the legacy trait will be removed altogether. Although we expect this trait to be used only in the standard library, we suspect it may be in use elsehwere, so we're landing this change separately to identify any surprising breakages. It's known that this trait is used within the Rust for Linux project; a patch is in progress to remove their dependency. This is a part of the arbitrary self types v2 project, https://github.com/rust-lang/rfcs/pull/3519 https://github.com/rust-lang/rust/issues/44874 r? @wesleywiser
2024-10-21move strict provenance lints to new feature gate, remove old feature gatesRalf Jung-1/+2
2024-10-16Partially stabilize const_pinGeorge Bateman-1/+0
2024-10-16Auto merge of #131767 - cuviper:bump-stage0, r=Mark-Simulacrumbors-2/+0
Bump bootstrap compiler to 1.83.0-beta.1 https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday