rust/library/alloc/src
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
..
boxed Implement some conversions using Box::clone_from_ref 2025-11-19 13:34:03 -06:00
collections Auto merge of #147893 - fee1-dead-contrib:constheapheapheap, r=oli-obk 2026-01-06 11:39:17 +00:00
ffi library: Fix typo in the documentatio of Cstring::from_vec_with_nul 2026-01-02 14:54:36 +01:00
raw_vec fix rustfmt and bless tidy/tests 2026-01-01 19:17:11 -05:00
vec Auto merge of #147893 - fee1-dead-contrib:constheapheapheap, r=oli-obk 2026-01-06 11:39:17 +00:00
wtf8 Stabilize char_max_len 2025-11-14 18:23:19 +03:00
alloc.rs address review comments; fix CI 2026-01-01 19:17:11 -05:00
borrow.rs alloc: Move Cow impl to existing ones 2026-01-02 20:40:04 +01:00
boxed.rs Update tracking issue for PinCoerceUnsized 2025-12-17 20:26:41 +00:00
bstr.rs Fully test the alloc crate through alloctests 2025-03-07 19:11:13 +00:00
fmt.rs replace version placeholder 2025-12-19 15:04:30 -08:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Auto merge of #147893 - fee1-dead-contrib:constheapheapheap, r=oli-obk 2026-01-06 11:39:17 +00:00
macros.rs Streamline the format macro. 2025-04-28 06:56:13 +10:00
rc.rs Update tracking issue for PinCoerceUnsized 2025-12-17 20:26:41 +00:00
slice.rs stabilize [T]::array_windows 2025-12-02 00:37:17 +07:00
str.rs optimization: Don't include ASCII characters in Unicode tables 2025-09-07 15:21:24 +02:00
string.rs Auto merge of #149694 - lolbinarycat:alloc-extend-slice-of-str-spec, r=Mark-Simulacrum 2025-12-29 22:07:30 +00:00
sync.rs Update tracking issue for PinCoerceUnsized 2025-12-17 20:26:41 +00:00
task.rs Stabilize noop_waker 2024-12-05 14:14:17 -08:00