diff options
| author | Ben Kimock <kimockb@gmail.com> | 2024-09-17 22:26:21 -0400 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2024-09-17 22:26:21 -0400 |
| commit | 46761442b00eb02dc1d4cba23c50b05dc816fc90 (patch) | |
| tree | 0566940a4e7ddf66a9b04c5b37d7f271a153fd5e | |
| parent | 28e8f01c2a2f33fb4214925a704e3223b372cad5 (diff) | |
| download | rust-46761442b00eb02dc1d4cba23c50b05dc816fc90.tar.gz rust-46761442b00eb02dc1d4cba23c50b05dc816fc90.zip | |
read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed
| -rw-r--r-- | library/alloc/src/alloc.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index de58b06545b..a91659b6de5 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -171,7 +171,13 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { - unsafe { __rust_alloc_zeroed(layout.size(), layout.align()) } + unsafe { + // Make sure we don't accidentally allow omitting the allocator shim in + // stable code until it is actually stabilized. + core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable); + + __rust_alloc_zeroed(layout.size(), layout.align()) + } } #[cfg(not(test))] |
