@@ -3881,7 +3881,8 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38813881#[ stable( feature = "rust1" , since = "1.0.0" ) ]
38823882pub unsafe fn from_raw_parts < ' a , T > ( data : * const T , len : usize ) -> & ' a [ T ] {
38833883 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,
38853886 "attempt to create slice covering half the address space" ) ;
38863887 Repr { raw : FatPtr { data, len } } . rust
38873888}
@@ -3904,9 +3905,10 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
39043905#[ stable( feature = "rust1" , since = "1.0.0" ) ]
39053906pub unsafe fn from_raw_parts_mut < ' a , T > ( data : * mut T , len : usize ) -> & ' a mut [ T ] {
39063907 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,
39083910 "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
39103912}
39113913
39123914/// Converts a reference to T into a slice of length 1 (without copying).
0 commit comments