Unnamed repository; edit this file 'description' to name the repository.
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.
bors 3 months ago
parent d776d9e · parent 10d16fc · commit f7e2c1e
0 files changed, 0 insertions, 0 deletions