Skip to content

Commit 6853013

Browse files
committed
Teach llvm backend how to fall back to default bodies
1 parent 01a21fb commit 6853013

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

core/src/intrinsics.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,18 +2368,6 @@ extern "rust-intrinsic" {
23682368
#[rustc_nounwind]
23692369
pub fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8;
23702370

2371-
/// Allocates a block of memory at compile time.
2372-
/// At runtime, just returns a null pointer.
2373-
///
2374-
/// # Safety
2375-
///
2376-
/// - The `align` argument must be a power of two.
2377-
/// - At compile time, a compile error occurs if this constraint is violated.
2378-
/// - At runtime, it is not checked.
2379-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
2380-
#[rustc_nounwind]
2381-
pub fn const_allocate(size: usize, align: usize) -> *mut u8;
2382-
23832371
/// Deallocates a memory which allocated by `intrinsics::const_allocate` at compile time.
23842372
/// At runtime, does nothing.
23852373
///
@@ -2594,6 +2582,22 @@ pub(crate) const unsafe fn debug_assertions() -> bool {
25942582
cfg!(debug_assertions)
25952583
}
25962584

2585+
/// Allocates a block of memory at compile time.
2586+
/// At runtime, just returns a null pointer.
2587+
///
2588+
/// # Safety
2589+
///
2590+
/// - The `align` argument must be a power of two.
2591+
/// - At compile time, a compile error occurs if this constraint is violated.
2592+
/// - At runtime, it is not checked.
2593+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
2594+
#[rustc_nounwind]
2595+
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2596+
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
2597+
// const eval overrides this function, but runtime code should always just return null pointers.
2598+
crate::ptr::null_mut()
2599+
}
2600+
25972601
// Some functions are defined here because they accidentally got made
25982602
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
25992603
// (`transmute` also falls into this category, but it cannot be wrapped due to the

0 commit comments

Comments
 (0)