File tree 2 files changed +18
-2
lines changed
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 {
6580
6580
}
6581
6581
6582
6582
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
+ }
6584
6592
6585
6593
// This branch shouldn't be taken in practice, but since we
6586
6594
// 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 {
72
72
#[ inline]
73
73
fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , ( ) > {
74
74
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
+ }
76
84
None => Err ( ( ) ) ,
77
85
}
78
86
}
You can’t perform that action at this time.
0 commit comments