about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-08-03Fix documentation of Rc as From<Vec<T>>July Tikhonov-3/+3
2023-08-02str.rs: remove "Basic usage" textTshepang Mbambo-6/+0
Only one example is given
2023-08-02string.rs: remove "Basic usage" textTshepang Mbambo-72/+1
Only a single example is given
2023-07-30Rollup merge of #95965 - CAD97:const-weak-new, r=workingjubileeJubilee-2/+2
Stabilize const-weak-new This is a fairly uncontroversial library stabilization, so I'm going ahead and proposing it to ride the trains to stable. This stabilizes the following APIs, which are defined to be non-allocating constructors. ```rust // alloc::rc impl<T> Weak<T> { pub const fn new() -> Weak<T>; } // alloc::sync impl<T> Weak<T> { pub const fn new() -> Weak<T>; } ``` Closes #95091 ``@rustbot`` modify labels: +needs-fcp
2023-07-30Stabilize const-weak-newCAD97-2/+2
Bump its stabilization version several times along the way to accommodate changes in release processes. Co-authored-by: Mara Bos <m-ou.se@m-ou.se> Co-authored-by: Trevor Gross <t.gross35@gmail.com>
2023-07-30Avoid using ptr::Unique in LinkedList codeRyan Lowe-11/+13
2023-07-30Rollup merge of #114223 - ryanoneill:vec-indexing-doc-language, r=workingjubileeMatthias Krüger-1/+1
Documentation: Fix Stilted Language in Vec->Indexing Problem Language in the Vec->Indexing documentation sounds stilted due to incorrect word ordering: "... type allows to access values by index." Solution Reorder words in the Vec->Indexing documentation to flow better: "... type allows access to values by index." The phrase "allows access to" also matches other existing documentation.
2023-07-30Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-deadbors-0/+8
Rollup of 3 pull requests Successful merges: - #112151 (Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound) - #113512 (Updated lines doc to include trailing carriage return note) - #114203 (Effects: don't print `host` param in diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-30Rollup merge of #112151 - chloekek:patch-1, r=workingjubileefee1-dead-0/+8
Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound It wasn’t quite clear to me how these methods would interpret inclusive bounds so I added examples for those.
2023-07-30Auto merge of #112280 - zica87:master, r=workingjubileebors-13/+0
Remove redundant example of `BTreeSet::iter` The usage and that `Values returned by the iterator are returned in ascending order` are already demonstrated by the other example and the description, so I removed the useless one.
2023-07-29Documentation: Fix Stilted Language in Vec->IndexingRyan O'Neill-1/+1
Problem Language in the Vec->Indexing documentation sounds stilted due to incorrect word ordering: "... type allows to access values by index." Solution Reorder words in the Vec->Indexing documentation to flow better: "... type allows access to values by index." The phrase "allows access to" also matches other existing documentation.
2023-07-28btree/map.rs: remove "Basic usage" textTshepang Mbambo-54/+0
Not useful, for there is just a single example
2023-07-28add LinkedList::{retain,retain_mut}TennyZhuang-0/+93
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2023-07-25Add note that Vec::as_mut_ptr() does not materialize a reference to the ↵Manish Goregaokar-0/+35
internal buffer
2023-07-25Auto merge of #114020 - steffahn:hide-specialized-ToString-impls, r=thomccbors-0/+9
Hide `ToString` implementations that specialize the default one The status quo is highly confusing, since the overlap is not apparent, and specialization is not a feature of Rust. This change addresses #87545; I'm not certain if it closes/fixes it entirely, since that issue might also be tracking the question of a *general* solution for hiding the documentation for specializing impls automatically. Before ![Screenshot_20230724_234210](https://github.com/rust-lang/rust/assets/3986214/54bbe659-1790-4e95-a5d8-5426e710ceb8) After ![Screenshot_20230724_234255](https://github.com/rust-lang/rust/assets/3986214/ee645d6e-c1c0-40c0-a0d3-a5c5f3dae65e)
2023-07-24Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>`Nikolai Vazquez-0/+42
2023-07-24remove additional [allow(unused_unsafe)]James Dietz-1/+0
2023-07-24Hide `ToString` implementations that specialize the default onesFrank Steffahn-0/+9
The status quo is highly confusing, since the overlap is not apparent, and specialization is not a feature of Rust. This addresses #87545; I'm not certain if it closes it, since that issue might also be trackign a *general* solution for hiding specializing impls automatically.
2023-07-22Auto merge of #113954 - matthiaskrgr:rollup-e2r9suz, r=matthiaskrgrbors-8/+8
Rollup of 6 pull requests Successful merges: - #112490 (Remove `#[cfg(all())]` workarounds from `c_char`) - #113252 (Update the tracking issue for `const_cstr_from_ptr`) - #113442 (Allow limited access to `OsString` bytes) - #113876 (fix docs & example for `std::os::unix::prelude::FileExt::write_at`) - #113898 (Fix size_hint for EncodeUtf16) - #113934 (Multibyte character removal in String::pop and String::remove doctests) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-22Auto merge of #113224 - zachs18:vec_extend_remove_allocator_lifetime, r=cuviperbors-3/+3
Remove lifetime bound for A for `impl Extend<&'a T> for Vec<T, A>`. The lifetime of the references being copied from is unrelated to the allocator. Compare with [`impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A>`](https://doc.rust-lang.org/alloc/collections/vec_deque/struct.VecDeque.html#impl-Extend%3C%26'a+T%3E-for-VecDeque%3CT,+A%3E) which does not have the `A: 'a` bound already. Since `Allocator` is unstable, the only possible `A` on stable is `Global`, and `Global: 'static`, so this change is not (should not be) observable on stable (or without `#![feature(allocator_api)]`). [This is observable on nightly](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8c4aa166c6116a90593d2934d30cfeb3).
2023-07-21Demonstrate multibyte character removal in String::pop and String::remove ↵Andrew Tribick-8/+8
doctests
2023-07-18std::error::Error -> Trait Implementations: lifetimes consistency improvementWiktorPrzetacznik-8/+8
2023-07-18Make {Rc,Arc}::allocator associated functionsMike Hommey-4/+12
2023-07-17Auto merge of #89132 - Cyborus04:rc_allocator_support, r=Amanieubors-300/+1518
Add support for allocators in `Rc` & `Arc` Adds the ability for `std::rc:Rc`, `std::rc::Weak`, `std::sync::Arc`, and `std::sync::Weak` to live in custom allocators
2023-07-16Implement `From<{&,&mut} [T; N]>` for `Vec<T>`EFanZh-0/+30
2023-07-14Rollup merge of #113662 - pedroclobo:vec-deque-rotate, r=thomccMatthias Krüger-25/+25
Rename VecDeque's `rotate_left` and `rotate_right` parameters This pull request introduces a modification to the `VecDeque` collection, specifically the `rotate_left` and `rotate_right` functions, by renaming the parameter associated with these functions. The rationale behind this change is to provide clearer and more consistent naming for the parameter that specifies the number of places to rotate the double-ended queue. By using `n` as the parameter name in both functions, it becomes easier to understand and remember the purpose of the parameter.
2023-07-14Auto merge of #113113 - Amanieu:box-vec-zst, r=Mark-Simulacrumbors-25/+49
Eliminate ZST allocations in `Box` and `Vec` This PR fixes 2 issues with `Box` and `RawVec` related to ZST allocations. Specifically, the `Allocator` trait requires that: - If you allocate a zero-sized layout then you must later deallocate it, otherwise the allocator may leak memory. - You cannot pass a ZST pointer to the allocator that you haven't previously allocated. These restrictions exist because an allocator implementation is allowed to allocate non-zero amounts of memory for a zero-sized allocation. For example, `malloc` in libc does this. Currently, ZSTs are handled differently in `Box` and `Vec`: - `Vec` never allocates when `T` is a ZST or if the vector capacity is 0. - `Box` just blindly passes everything on to the allocator, including ZSTs. This causes problems due to the free conversions between `Box<[T]>` and `Vec<T>`, specifically that ZST allocations could get leaked or a dangling pointer could be passed to `deallocate`. This PR fixes this by changing `Box` to not allocate for zero-sized values and slices. It also fixes a bug in `RawVec::shrink` where shrinking to a size of zero did not actually free the backing memory.
2023-07-13Fix VecDeque's rotate_left and rotate_right panic testsPedro Lobo-2/+2
2023-07-13Rename VecDeque's rotate_left and rotate_right parametersPedro Lobo-23/+23
2023-07-13Eliminate ZST allocations in `Box` and `Vec`Amanieu d'Antras-25/+49
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-21/+0
2023-07-12Replace version placeholder to 1.72Mark Rousskov-1/+1
2023-07-08mark as stableTristan Guichaoua-1/+1
2023-07-08impl `From<&[T; N]>` for `Cow<[T]>`Tristan Guichaoua-0/+13
2023-07-04Revert "alloc: Allow comparing `Box`s over different allocators"Trevor Gross-26/+9
This reverts commit 001b081cc1bfd24657e2dccbd9c8289f9a9d67a5. This change was done as the above commit introduces a regression in type inference. Regression test located at `tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs`
2023-07-02Rollup merge of #113253 - nurmukhametdaniyar:rc_from_cstr_doc_fix, r=NilstriebMatthias Krüger-1/+1
Fixed documentation of from<CString> for Rc<CStr>: Arc -> Rc Fix #113131
2023-07-02fixed documentation of from<CString> for Rc<CStr>: Arc -> RcDaniyar Nurmukhamet-1/+1
2023-07-01Remove lifetime bound for A for `impl Extend<&'a T> for Vec<T, A>`.Zachary S-3/+3
2023-06-30Add support for allocators in `Rc` and `Arc`Cyborus04-1/+1
2023-06-30Add support for allocators in `Rc` and `Arc`Cyborus04-300/+1518
2023-06-29Fix document examples of Vec::from_raw_parts and Vec::from_raw_parts_inLi Zhanhui-14/+15
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
2023-06-27Rollup merge of #112628 - gootorov:box_alloc_partialeq, r=joshtriplettMatthias Krüger-9/+26
Allow comparing `Box`es with different allocators Currently, comparing `Box`es over different allocators is not allowed: ```Rust error[E0308]: mismatched types --> library/alloc/tests/boxed.rs:22:20 | 22 | assert_eq!(b1, b2); | ^^ expected `Box<{integer}, ConstAllocator>`, found `Box<{integer}, AnotherAllocator>` | = note: expected struct `Box<{integer}, ConstAllocator>` found struct `Box<{integer}, AnotherAllocator>` For more information about this error, try `rustc --explain E0308`. error: could not compile `alloc` (test "collectionstests") due to previous error ``` This PR lifts this limitation
2023-06-26Rollup merge of #112677 - the8472:remove-unusued-field, r=JohnTitorTakayuki Maeda-9/+1
remove unused field Followup to #104455. The field is no longer needed since ExtractIf (previously DrainFilter) doesn't keep draining in its drop impl.
2023-06-21Auto merge of #112877 - Nilstrieb:rollup-5g5hegl, r=Nilstriebbors-2/+7
Rollup of 6 pull requests Successful merges: - #112632 (Implement PartialOrd for `Vec`s over different allocators) - #112759 (Make closure_saved_names_of_captured_variables a query. ) - #112772 (Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`) - #112790 (Syntactically accept `become` expressions (explicit tail calls experiment)) - #112830 (More codegen cleanups) - #112844 (Add retag in MIR transform: `Adt` for `Unique` may contain a reference) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-21Rollup merge of #112632 - gootorov:vec_alloc_partialeq, r=dtolnayNilstrieb-2/+7
Implement PartialOrd for `Vec`s over different allocators It is already possible to `PartialEq` `Vec`s with different allocators, but that is not the case with `PartialOrd`.
2023-06-21Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieubors-10/+10
Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata FCP completed in https://github.com/rust-lang/rust/issues/103763#issuecomment-1362267967 Closes #103763
2023-06-19Introduce `alloc::::UniqueRc`Eric Holk-3/+184
This is an `Rc` that is guaranteed to only have one strong reference. Because it is uniquely owned, it can safely implement `DerefMut`, which allows programs to have an initialization phase where structures inside the `Rc` can be mutated. The `UniqueRc` can then be converted to a regular `Rc`, allowing sharing and but read-only access. During the "initialization phase," weak references can be created, but attempting to upgrade these will fail until the `UniqueRc` has been converted to a regular `Rc`. This feature can be useful to create cyclic data structures. This API is an implementation based on the feedback provided to the ACP at https://github.com/rust-lang/libs-team/issues/90.
2023-06-18alloc: Allow comparing `Box`s over different allocatorsIgor Gutorov-9/+26
2023-06-18alloc: Implement PartialOrd for `Vec`s over different allocatorsIgor Gutorov-2/+7