Commit graph

386 commits

Author SHA1 Message Date
mu001999
0dc1556968 Remove unused features in library 2026-02-13 09:25:50 +08:00
Lukas Bergdoll
2f3b952349 Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Pavel Grigorenko
e212560317 Stabilize alloc_layout_extra 2026-01-11 16:39:18 +03:00
bors
74fd7516da Auto merge of #147893 - fee1-dead-contrib:constheapheapheap, r=oli-obk
`Vec::push` in consts MVP

Example:

```rust
const X: &'static [u32] = {
    let mut v = Vec::with_capacity(6);
    let mut x = 1;
    while x < 42 {
        v.push(x);
        x *= 2;
    }
    assert!(v.len() == 6);
    v.const_make_global()
};

assert_eq!([1, 2, 4, 8, 16, 32], X);
```

Oh this is fun...

* We split out the implementation of `Global` such that it calls `intrinsics::const_allocate` and `intrinsics::const_deallocate` during compile time. This is achieved using `const_eval_select`
* This allows us to `impl const Allocator for Global`
* We then constify everything necessary for `Vec::with_capacity` and `Vec::push`.
* Added `Vec::const_make_global` to leak and intern the final value via `intrinsics::const_make_global`. If we see any pointer in the final value of a `const` that did not call `const_make_global`, we error as implemented in rust-lang/rust#143595.

r? `@rust-lang/wg-const-eval`

To-do for me:
* [x] Assess the rustdoc impact of additional bounds in the method
* [x] ~~Increase test coverage~~ I think this is enough for an unstable feature.
2026-01-06 11:39:17 +00:00
Khashayar Fereidani
0330cc2446 Add feature flag likely/unlikely for alloc 2026-01-05 13:14:11 +03:30
Deadbeef
a913065d80 fix rustfmt and bless tidy/tests 2026-01-01 19:17:11 -05:00
Deadbeef
47864e80cb address review comments; fix CI 2026-01-01 19:17:11 -05:00
Deadbeef
3982d3e706 Vec::push in consts MVP 2026-01-01 19:17:11 -05:00
Marijn Schouten
eea3d794ff LinkedList: use Box::into_non_null_with_allocator 2025-12-29 19:08:34 +00:00
Matthias Krüger
8a6f82efac
Rollup merge of #148814 - bend-n:stabilize_array_windows, r=scottmcm
stabilize `array_windows`

Tracking issue: rust-lang/rust#75027
Closes: rust-lang/rust#75027
FCP completed: https://github.com/rust-lang/rust/issues/75027#issuecomment-3477510526
2025-12-06 09:57:59 +01:00
bendn
919e46f4d4
stabilize [T]::array_windows 2025-12-02 00:37:17 +07:00
bendn
d67f99af2e
fix 2025-11-27 17:55:34 +07:00
Matthias Krüger
5dd82e8ed9
Rollup merge of #145610 - GrigorenkoPV:char_max_len, r=Amanieu
Stabilize `char_max_len`

Tracking issue: rust-lang/rust#121714

r? t-libs-api

`@rustbot` label +needs-fcp -T-libs +T-libs-api

Closes rust-lang/rust#121714
2025-11-17 18:07:31 +01:00
Stuart Cook
7b73b2126d
Rollup merge of #148416 - GrigorenkoPV:vec_recycle, r=Mark-Simulacrum
`vec_recycle`: implementation

Tracking issue: rust-lang/rust#148227

Going with the `TransmuteFrom` approach suggested in https://github.com/rust-lang/libs-team/issues/674#issuecomment-3457795183, but a bit simplified.

Currently does not work in some places where it should due to the limitations of the current implementation of the transmutability analysis: https://github.com/rust-lang/rust/issues/148227#issuecomment-3478099591
2025-11-16 14:39:56 +11:00
Pavel Grigorenko
f9dcc6b21c Stabilize char_max_len 2025-11-14 18:23:19 +03:00
Mara Bos
ad1789a5f0 Expose fmt::Arguments::from_str as unstable. 2025-11-13 15:57:51 +01:00
Pavel Grigorenko
33da7285ac vec_recycle: implementation 2025-11-11 14:01:02 +03:00
joboet
5fb5861765
(almost) get rid of the unsound #[rustc_unsafe_specialization_marker] on Copy, introduce TrivialClone 2025-11-09 15:51:25 +01:00
Antoni Spaanderman
5b96677adb
add specialization for extend_front and prepend with copied slice iterator 2025-11-03 12:35:30 +01:00
Antoni Spaanderman
e23c1551a7
implement VecDeque extend_front and prepend, add tests 2025-11-01 18:30:01 +01:00
bors
82ae0ee648 Auto merge of #144420 - Qelxiros:smart_pointer_try_map, r=joboet
smart pointer (try_)map

Tracking issue: rust-lang/rust#144419
2025-10-31 17:09:47 +00:00
Jeremy Smart
9c5be677d0
add {Box, (Unique){Rc, Arc}}::(try_)map 2025-10-31 10:13:51 -04:00
William Venner
8ed7fca74c Add String::replace_first and String::replace_last
Rebased and modified by zachs18.

Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2025-10-21 16:11:55 -05:00
Matthias Krüger
47bd38c2f1
Rollup merge of #145685 - Qelxiros:cell_get_cloned, r=programmerjake,tgross35
add CloneFromCell and Cell::get_cloned

Tracking issue: rust-lang/rust#145329
2025-10-04 17:11:08 +02:00
Jeremy Smart
08b4641f50
add CloneFromCell and Cell::get_cloned 2025-10-01 18:47:09 -04:00
Guillaume Gomez
254a2139f6 Remove cfg(bootstrap) for doc_cfg feature following #141925 2025-09-27 11:29:49 +02:00
Guillaume Gomez
a7ed9bf6c7 fmt 2025-09-27 11:29:49 +02:00
Guillaume Gomez
fccba2c341 Remove doc_cfg_hide feature 2025-09-27 11:29:49 +02:00
Guillaume Gomez
63aefe0737 Strenghten checks for doc(auto_cfg(show/hide)) attributes 2025-09-27 11:29:48 +02:00
Guillaume Gomez
7c00bccd3b Implement RFC 3631 2025-09-27 11:29:48 +02:00
ltdk
1c64d3e6d1 Constify conversion traits 2025-09-01 21:38:26 -04:00
ltdk
2914291e09 Move WTF-8 code from std to core/alloc 2025-08-20 20:31:33 -04:00
ltdk
d6945f6d8c Add cast_init and cast_uninit methods for pointers 2025-08-12 16:57:56 -04:00
Scott McMurray
173926da2b Remove [T]::array_chunks(_mut) 2025-07-27 23:03:07 -07:00
bors
3014e79f9c Auto merge of #143877 - xizheyin:143813, r=scottmcm,saethlin
`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-15 14:47:10 +00:00
xizheyin
1cab09ed9c
std::vec: Upgrade debug_assert to UB check in set_len
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13 16:06:53 +08:00
Esteban Küber
c3301503b9 Make Default const and add some const Default impls
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-07 22:09:37 +00:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00
Ralf Jung
3164ca8bb4 stabilize nonnull_provenance 2025-06-09 12:36:24 +02:00
Josh Stone
c87b072952 Remove more library bootstrap 2025-06-02 14:46:19 -07:00
Christopher Durham
4d93f60568 use generic Atomic type where possible
in core/alloc/std only for now, and ignoring test files

Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-27 02:18:08 +03:00
lincot
09d5bcf1ad
Speed up String::push and String::insert
Improve performance of `String` methods by avoiding unnecessary memcpy
for the character bytes, with added codegen check to ensure compliance.
2025-04-09 13:06:10 +03:00
James Wainwright
78e9621390 Pass Alignment for RawVecInner::new_in
Encodes the safety constraint that `Unique`'s pointer must be non-zero
into the API.
2025-03-26 21:41:11 +00:00
Jacob Pratt
720eacf086
Rollup merge of #136642 - bjorn3:separate_alloctest_crate, r=cuviper
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-08 01:27:20 -05:00
bjorn3
ae5687e4b0 Fully test the alloc crate through alloctests
For the tests that make use of internal implementation details, we
include the module to test using #[path] in alloctests now.
2025-03-07 19:11:13 +00:00
Santiago Pastorino
5a6d00c05d
Add allow(incomplete_features) to alloc 2025-03-06 17:58:35 -03:00
Santiago Pastorino
dcdfd551f0
Add UseCloned trait related code 2025-03-06 17:58:32 -03:00
Slanterns
3786a7a908
stabilize box_uninit_write 2025-03-01 20:11:39 +08:00
Matthias Krüger
929423a4f0
Rollup merge of #137121 - bend-n:master, r=Noratrieb
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-23 00:16:18 +01:00
Matthias Krüger
84e9f29007
Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-se
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-19 21:16:01 +01:00