Skip to content

Commit 365bdc0

Browse files
committed
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.
2 parents 5f29d12 + c03cd50 commit 365bdc0

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)