@@ -43,15 +43,14 @@ impl<F> DerefMut for OwnedHeap<F> {
4343pub fn new_heap ( ) -> OwnedHeap < impl Sized > {
4444 const HEAP_SIZE : usize = 1000 ;
4545 let mut heap_space = Box :: new ( Chonk :: < HEAP_SIZE > :: new ( ) ) ;
46- let data = & mut heap_space. data ;
46+ let data = & mut Box :: leak ( heap_space) . data ;
4747 let assumed_location = data. as_mut_ptr ( ) . cast ( ) ;
4848
4949 let heap = unsafe { Heap :: new ( data. as_mut_ptr ( ) . cast ( ) , data. len ( ) ) } ;
5050 assert_eq ! ( heap. bottom( ) , assumed_location) ;
5151 assert_eq ! ( heap. size( ) , align_down_size( HEAP_SIZE , size_of:: <usize >( ) ) ) ;
52-
5352 let drop = move || {
54- let _ = heap_space;
53+ // let _ = heap_space;
5554 } ;
5655 OwnedHeap { heap, _drop : drop }
5756}
@@ -60,7 +59,7 @@ fn new_max_heap() -> OwnedHeap<impl Sized> {
6059 const HEAP_SIZE : usize = 1024 ;
6160 const HEAP_SIZE_MAX : usize = 2048 ;
6261 let mut heap_space = Box :: new ( Chonk :: < HEAP_SIZE_MAX > :: new ( ) ) ;
63- let data = & mut heap_space. data ;
62+ let data = & mut Box :: leak ( heap_space) . data ;
6463 let start_ptr = data. as_mut_ptr ( ) . cast ( ) ;
6564
6665 // Unsafe so that we have provenance over the whole allocation.
@@ -69,19 +68,19 @@ fn new_max_heap() -> OwnedHeap<impl Sized> {
6968 assert_eq ! ( heap. size( ) , HEAP_SIZE ) ;
7069
7170 let drop = move || {
72- let _ = heap_space;
71+ // let _ = heap_space;
7372 } ;
7473 OwnedHeap { heap, _drop : drop }
7574}
7675
7776fn new_heap_skip ( ct : usize ) -> OwnedHeap < impl Sized > {
7877 const HEAP_SIZE : usize = 1000 ;
7978 let mut heap_space = Box :: new ( Chonk :: < HEAP_SIZE > :: new ( ) ) ;
80- let data = & mut heap_space. data [ ct..] ;
79+ let data = & mut Box :: leak ( heap_space) . data [ ct..] ;
8180 let heap = unsafe { Heap :: new ( data. as_mut_ptr ( ) . cast ( ) , data. len ( ) ) } ;
8281
8382 let drop = move || {
84- let _ = heap_space;
83+ // let _ = heap_space;
8584 } ;
8685 OwnedHeap { heap, _drop : drop }
8786}
0 commit comments