Skip to content

Commit 4e97c6c

Browse files
committed
mark const_(de)allocate intrinsics as suitable for Miri
1 parent 821d23b commit 4e97c6c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

library/core/src/intrinsics.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -2821,8 +2821,10 @@ pub const fn ub_checks() -> bool {
28212821
#[unstable(feature = "core_intrinsics", issue = "none")]
28222822
#[rustc_nounwind]
28232823
#[rustc_intrinsic]
2824+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
28242825
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
2825-
// const eval overrides this function, but runtime code should always just return null pointers.
2826+
// const eval overrides this function, but runtime code for now just returns null pointers.
2827+
// See <https://github.com/rust-lang/rust/issues/93935>.
28262828
crate::ptr::null_mut()
28272829
}
28282830

@@ -2840,7 +2842,10 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
28402842
#[unstable(feature = "core_intrinsics", issue = "none")]
28412843
#[rustc_nounwind]
28422844
#[rustc_intrinsic]
2843-
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
2845+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
2846+
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
2847+
// Runtime NOP
2848+
}
28442849

28452850
/// `ptr` must point to a vtable.
28462851
/// The intrinsic will return the size stored in that vtable.

0 commit comments

Comments
 (0)