@@ -3881,7 +3881,8 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
3881
3881
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
3882
3882
pub unsafe fn from_raw_parts < ' a , T > ( data : * const T , len : usize ) -> & ' a [ T ] {
3883
3883
debug_assert ! ( data as usize % mem:: align_of:: <T >( ) == 0 , "attempt to create unaligned slice" ) ;
3884
- debug_assert ! ( len * mem:: size_of:: <T >( ) < isize :: MAX as usize ,
3884
+ let size = mem:: size_of :: < T > ( ) ;
3885
+ debug_assert ! ( size == 0 || len < ( isize :: MAX as usize + size - 1 ) / size,
3885
3886
"attempt to create slice covering half the address space" ) ;
3886
3887
Repr { raw : FatPtr { data, len } } . rust
3887
3888
}
@@ -3904,9 +3905,10 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
3904
3905
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
3905
3906
pub unsafe fn from_raw_parts_mut < ' a , T > ( data : * mut T , len : usize ) -> & ' a mut [ T ] {
3906
3907
debug_assert ! ( data as usize % mem:: align_of:: <T >( ) == 0 , "attempt to create unaligned slice" ) ;
3907
- debug_assert ! ( len * mem:: size_of:: <T >( ) < isize :: MAX as usize ,
3908
+ let size = mem:: size_of :: < T > ( ) ;
3909
+ debug_assert ! ( size == 0 || len < ( isize :: MAX as usize + size - 1 ) / size,
3908
3910
"attempt to create slice covering half the address space" ) ;
3909
- Repr { raw : FatPtr { data, len} } . rust_mut
3911
+ Repr { raw : FatPtr { data, len } } . rust_mut
3910
3912
}
3911
3913
3912
3914
/// Converts a reference to T into a slice of length 1 (without copying).
0 commit comments