Skip to content

Commit

Permalink
mark const_(de)allocate intrinsics as suitable for Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 4, 2024
1 parent 821d23b commit 4e97c6c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2821,8 +2821,10 @@ pub const fn ub_checks() -> bool {
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind]
#[rustc_intrinsic]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
// const eval overrides this function, but runtime code should always just return null pointers.
// const eval overrides this function, but runtime code for now just returns null pointers.
// See <https://github.com/rust-lang/rust/issues/93935>.
crate::ptr::null_mut()
}

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

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

0 comments on commit 4e97c6c

Please sign in to comment.