diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-07-17 03:58:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 03:58:30 +0200 |
| commit | 83288db888606371dfac6491fc5720d31774aa8c (patch) | |
| tree | be64ca7a1c03e75b28e130466c847a77850732a5 /library/alloc | |
| parent | 2f879530d223e8b10636cb1d80d08cf5c74606e8 (diff) | |
| parent | 0bf0860a0ef285fe3e4eb3b176006c14d8ca9d8d (diff) | |
| download | rust-83288db888606371dfac6491fc5720d31774aa8c.tar.gz rust-83288db888606371dfac6491fc5720d31774aa8c.zip | |
Rollup merge of #143595 - fee1-dead-contrib:push-sylpykzkmynr, r=RalfJung,fee1-dead
add `const_make_global`; err for `const_allocate` ptrs if didn't call Implements as discussed on Zulip: [#t-compiler/const-eval > const heap](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const.20heap/with/527125421) r? ```@rust-lang/wg-const-eval``` Fixes https://github.com/rust-lang/rust/issues/129233
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/boxed/thin.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 21425b9846e..1cce36606d2 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -5,7 +5,7 @@ use core::error::Error; use core::fmt::{self, Debug, Display, Formatter}; #[cfg(not(no_global_oom_handling))] -use core::intrinsics::const_allocate; +use core::intrinsics::{const_allocate, const_make_global}; use core::marker::PhantomData; #[cfg(not(no_global_oom_handling))] use core::marker::Unsize; @@ -340,9 +340,10 @@ impl<H> WithHeader<H> { alloc.add(metadata_offset).cast(); // SAFETY: `*metadata_ptr` is within the allocation. metadata_ptr.write(ptr::metadata::<Dyn>(ptr::dangling::<T>() as *const Dyn)); - + // SAFETY: valid heap allocation + const_make_global(alloc); // SAFETY: we have just written the metadata. - &*(metadata_ptr) + &*metadata_ptr } }; |
