diff --git a/examples/rust/custom-heap/src/entrypoint.rs b/examples/rust/custom-heap/src/entrypoint.rs index 4f7df1a97f2..911619f22df 100644 --- a/examples/rust/custom-heap/src/entrypoint.rs +++ b/examples/rust/custom-heap/src/entrypoint.rs @@ -17,9 +17,9 @@ struct BumpAllocator; unsafe impl std::alloc::GlobalAlloc for BumpAllocator { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - const POS_PTR: *mut usize = HEAP_START_ADDRESS as *mut usize; - const TOP_ADDRESS: usize = HEAP_START_ADDRESS + HEAP_LENGTH; - const BOTTOM_ADDRESS: usize = HEAP_START_ADDRESS + size_of::<*mut u8>(); + const POS_PTR: *mut usize = HEAP_START_ADDRESS as usize as *mut usize; + const TOP_ADDRESS: usize = HEAP_START_ADDRESS as usize + HEAP_LENGTH; + const BOTTOM_ADDRESS: usize = HEAP_START_ADDRESS as usize + size_of::<*mut u8>(); let mut pos = *POS_PTR; if pos == 0 {