summary refs log tree commit diff
path: root/library/alloc/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-11-28Auto merge of #110353 - the8472:in-place-flatten-chunks, r=cuviperbors-0/+1
Expand in-place iteration specialization to Flatten, FlatMap and ArrayChunks This enables the following cases to collect in-place: ```rust let v = vec![[0u8; 4]; 1024] let v: Vec<_> = v.into_iter().flatten().collect(); let v: Vec<Option<NonZeroUsize>> = vec![NonZeroUsize::new(0); 1024]; let v: Vec<_> = v.into_iter().flatten().collect(); let v = vec![u8; 4096]; let v: Vec<_> = v.into_iter().array_chunks::<4>().collect(); ``` Especially the nicheful-option-flattening should be useful in real code.
2023-11-25Rollup merge of #117968 - Urgau:stabilize-ptr-addr-eq, r=dtolnayMichael Goulet-1/+0
Stabilize `ptr::addr_eq` This PR stabilize the `ptr_addr_eq` library feature, representing: ```rust // core::ptr pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool; ``` FCP has already started [on the tracking issue](https://github.com/rust-lang/rust/issues/116324#issuecomment-1813008697) and is waiting on the final period comment. Note: stabilizing this feature is somewhat of requirement for a new T-lang lint, cf. https://github.com/rust-lang/rust/pull/117758#issuecomment-1813183686.
2023-11-16Stabilize ptr_addr_eq library featureUrgau-1/+0
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-11-11Auto merge of #115694 - clarfonthey:std-hash-private, r=dtolnaybors-1/+1
Add `std::hash::{DefaultHasher, RandomState}` exports (needs FCP) This implements rust-lang/libs-team#267 to move the libstd hasher types to `std::hash` where they belong, instead of `std::collections::hash_map`. <details><summary>The below no longer applies, but is kept for clarity.</summary> This is a small refactor for #27242, which moves the definitions of `RandomState` and `DefaultHasher` into `std::hash`, but in a way that won't be noticed in the public API. I've opened rust-lang/libs-team#267 as a formal ACP to move these directly into the root of `std::hash`, but for now, they're at least separated out from the collections code in a way that will make moving that around easier. I decided to simply copy the rustdoc for `std::hash` from `core::hash` since I think it would be ideal for the two to diverge longer-term, especially if the ACP is accepted. However, I would be willing to factor them out into a common markdown document if that's preferred. </details>
2023-11-05Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnaybors-1/+0
Stabilize `const_maybe_uninit_zeroed` and `const_mem_zeroed` Make `MaybeUninit::zeroed` and `mem::zeroed` const stable. Newly stable API: ```rust // core::mem pub const unsafe fn zeroed<T>() ->; impl<T> MaybeUninit<T> { pub const fn zeroed() -> MaybeUninit<T>; } ``` This relies on features based around `const_mut_refs`. Per `@RalfJung,` this should be OK since we do not leak any `&mut` to the user. For this to be possible, intrinsics `assert_zero_valid` and `assert_mem_uninitialized_valid` were made const stable. Tracking issue: #91850 Zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const_mut_refs.60.20dependents r? libs-api `@rustbot` label -T-libs +T-libs-api +A-const-eval cc `@RalfJung` `@oli-obk` `@rust-lang/wg-const-eval`
2023-11-04Stabilize `const_maybe_uninit_zeroed`Trevor Gross-1/+0
Make `MaybeUninit::zeroed` const stable. Newly stable API: // core::mem impl<T> MaybeUninit<T> { pub const fn zeroed() -> MaybeUninit<T>; } Use of `const_mut_refs` should be acceptable since we do not leak the mutability. Tracking issue: #91850
2023-11-02Add insta-stable std::hash::{DefaultHasher, RandomState} exportsltdk-1/+1
2023-10-25Stabilize `[const_]pointer_byte_offsets`Maybe Waffle-1/+0
2023-10-20s/generator/coroutine/Oli Scherer-1/+1
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+2
2023-10-02Use `addr_eq` in `{Arc,Rc}::ptr_eq`Scott McMurray-0/+1
Since it's made for stuff like this (see 106447)
2023-09-03Expand in-place iteration specialization to Flatten, FlatMap and ArrayChunksThe 8472-0/+1
2023-09-03Stabilize the Saturating type (saturating_int_impl, gh-87920)Michael Watzko-1/+0
Also stabilizes saturating_int_assign_impl, gh-92354. And also make pub fns const where the underlying saturating_* fns became const in the meantime since the Saturating type was created.
2023-08-23Bump cfg(bootstrap)Mark Rousskov-2/+2
2023-08-22Auto merge of #113365 - dima74:diralik/add-deprecated-suggestions, ↵bors-0/+1
r=workingjubilee Add `suggestion` for some `#[deprecated]` items Consider code: ```rust fn main() { let _ = ["a", "b"].connect(" "); } ``` Currently it shows deprecated warning: ```rust warning: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join --> src/main.rs:2:24 | 2 | let _ = ["a", "b"].connect(" "); | ^^^^^^^ | = note: `#[warn(deprecated)]` on by default ``` This PR adds `suggestion` for `connect` and some other deprecated items, so the warning will be changed to this: ```rust warning: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join --> src/main.rs:2:24 | 2 | let _ = ["a", "b"].connect(" "); | ^^^^^^^ | = note: `#[warn(deprecated)]` on by default help: replace the use of the deprecated method | 2 | let _ = ["a", "b"].join(" "); | ^^^^ ```
2023-08-21Add `suggestion` for some `#[deprecated]` itemsDmitry Murzin-0/+1
2023-08-18resolve conflictsKyle Lin-0/+1
2023-08-15fix typo: affect -> effectRalf Jung-1/+1
2023-08-13core/any: remove Provider traitwayne warren-1/+0
* remove `impl Provider for Error` * rename `Demand` to `Request` * update docstrings to focus on the conceptual API provided by `Request` * move `core::any::{request_ref, request_value}` functions into `core::error` * move `core::any::tag`, `core::any::Request`, an `core::any::TaggedOption` into `core::error` * replace `provide_any` feature name w/ `error_generic_member_access` * move `core::error::request_{ref,value} tests into core::tests::error module * update unit and doc tests
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-06-11reorder attributes to make miri-test-libstd work againRalf Jung-5/+5
2023-05-05Stabilize const_ptr_readbors-1/+0
2023-05-03Add the basic `ascii::Char` typeScott McMurray-0/+1
2023-04-25Revert "Report allocation errors as panics"Matthias Krüger-1/+0
This reverts commit c9a6e41026d7aa27d897fb83e995447719753076.
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-0/+1
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-16Report allocation errors as panicsAmanieu d'Antras-0/+1
2023-04-16core is now compilableDeadbeef-2/+0
2023-04-13Add `tidy-alphabetical` to features in `alloc` & `std`Scott McMurray-21/+25
So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often.
2023-03-27Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-parts, ↵Matthias Krüger-1/+0
r=m-ou-se,the8472 Stabilize `nonnull_slice_from_raw_parts` FCP is done: https://github.com/rust-lang/rust/issues/71941#issuecomment-1100910416 Note that this doesn't const-stabilize `NonNull::slice_from_raw_parts` as `slice_from_raw_parts_mut` isn't const-stabilized yet. Given #67456 and #57349, it's not likely available soon, meanwhile, stabilizing only the feature makes some sense, I think. Closes #71941
2023-03-15Bump to latest betaMark Rousskov-2/+2
2023-02-01Stabilize feature 'cstr_from_bytes_until_nul'Trevor Gross-1/+0
2023-01-28Reintroduce multiple_supertrait_upcastable lintGary Guo-0/+2
2023-01-18Implement `alloc::vec::IsZero` for `Option<$NUM>` typesclubby789-0/+1
2023-01-14Add test of leaking a binary_heap PeekMutDavid Tolnay-0/+1
2023-01-04Update rand in the stdlib tests, and remove the getrandom feature from itThom Chiovoloni-0/+18
2023-01-03Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=AmanieuMichael Goulet-0/+1
default OOM handler: use non-unwinding panic, to match std handler The OOM handler in std will by default abort. This adjusts the default in liballoc to do the same, using the `can_unwind` flag on the panic info to indicate a non-unwinding panic. In practice this probably makes little difference since the liballoc default will only come into play in no-std situations where people write a custom panic handler, which most likely will not implement unwinding. But still, this seems more consistent. Cc `@rust-lang/wg-allocators,` https://github.com/rust-lang/rust/issues/66741
2023-01-02default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to ↵Ralf Jung-0/+1
match std handler
2022-12-30Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726Michael Goulet-2/+0
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint" This is a clean revert of #105484. I confirmed that reverting that PR fixes the regression reported in #106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** https://github.com/rust-lang/rust/issues/106247#issuecomment-1367174384 has an explanation of why #105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe. FYI `@nbdd0121` `@compiler-errors`
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-1/+1
2022-12-30Replace libstd, libcore, liballoc in docs.jonathanCogan-1/+1
2022-12-29Revert "Implement allow-by-default multiple_supertrait_upcastable lint"David Tolnay-2/+0
This reverts commit 5e44a65517bfcccbe6624a70b54b9f192baa94f3.
2022-12-28fix documenting private items of standard libraryLukas Markeffsky-0/+1
2022-12-28Update bootstrap cfgPietro Albini-1/+1
2022-12-28Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errorsfee1-dead-0/+2
Implement allow-by-default `multiple_supertrait_upcastable` lint The lint detects when an object-safe trait has multiple supertraits. Enabled in libcore and liballoc as they are low-level enough that many embedded programs will use them. r? `@nikomatsakis`
2022-12-28Rollup merge of #94145 - ssomers:binary_heap_tests, r=jyn514fee1-dead-0/+2
Test leaking of BinaryHeap Drain iterators Add test cases about forgetting the `BinaryHeap::Drain` iterator, and slightly fortifies some other test cases. Consists of separate commits that I don't think are relevant on their own (but I'll happily turn these into more PRs if desired).
2022-12-09Implement allow-by-default multiple_supertrait_upcastable lintGary Guo-0/+2
2022-11-22Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomccManish Goregaokar-0/+1
enable fuzzy_provenance_casts lint in liballoc and libstd r? ````@thomcc````
2022-11-20enable fuzzy_provenance_casts lint in liballocRalf Jung-0/+1
2022-11-15`VecDeque::resize` should re-use the buffer in the passed-in elementScott McMurray-0/+1
Today it always copies it for *every* appended element, but one of those clones is avoidable.