File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -6580,7 +6580,15 @@ mod test_map_with_mmap_allocations {
65806580 }
65816581
65826582 match NonNull :: new ( addr. cast ( ) ) {
6583- Some ( addr) => Ok ( NonNull :: slice_from_raw_parts ( addr, len) ) ,
6583+ Some ( data) => {
6584+ // SAFETY: this is NonNull::slice_from_raw_parts.
6585+ Ok ( unsafe {
6586+ NonNull :: new_unchecked ( core:: ptr:: slice_from_raw_parts_mut (
6587+ data. as_ptr ( ) ,
6588+ len,
6589+ ) )
6590+ } )
6591+ }
65846592
65856593 // This branch shouldn't be taken in practice, but since we
65866594 // cannot return null as a valid pointer in our type system,
Original file line number Diff line number Diff line change @@ -72,7 +72,15 @@ mod inner {
7272 #[ inline]
7373 fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , ( ) > {
7474 match unsafe { NonNull :: new ( alloc ( layout) ) } {
75- Some ( ptr) => Ok ( NonNull :: slice_from_raw_parts ( ptr, layout. size ( ) ) ) ,
75+ Some ( data) => {
76+ // SAFETY: this is NonNull::slice_from_raw_parts.
77+ Ok ( unsafe {
78+ NonNull :: new_unchecked ( core:: ptr:: slice_from_raw_parts_mut (
79+ data. as_ptr ( ) ,
80+ len,
81+ ) )
82+ } )
83+ }
7684 None => Err ( ( ) ) ,
7785 }
7886 }
You can’t perform that action at this time.
0 commit comments