@@ -2728,7 +2728,7 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
2728
2728
#[ requires( ub_checks:: can_dereference( x) && ub_checks:: can_write( x) ) ]
2729
2729
#[ requires( ub_checks:: can_dereference( y) && ub_checks:: can_write( y) ) ]
2730
2730
#[ requires( x. addr( ) != y. addr( ) || core:: mem:: size_of:: <T >( ) == 0 ) ]
2731
- #[ requires( ( x . addr ( ) >= y . addr ( ) + core :: mem :: size_of :: < T > ( ) ) || ( y . addr ( ) >= x . addr ( ) + core :: mem :: size_of:: <T >( ) ) ) ]
2731
+ #[ requires( ub_checks :: is_nonoverlapping ( x as * const ( ) , x as * const ( ) , size_of:: <T >( ) , 1 ) ) ]
2732
2732
pub const unsafe fn typed_swap < T > ( x : * mut T , y : * mut T ) {
2733
2733
// SAFETY: The caller provided single non-overlapping items behind
2734
2734
// pointers, so swapping them with `count: 1` is fine.
@@ -2943,11 +2943,11 @@ impl<P: ?Sized, T: ptr::Thin> AggregateRawPtr<*mut T> for *mut P {
2943
2943
#[ inline( always) ]
2944
2944
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
2945
2945
#[ rustc_diagnostic_item = "ptr_copy_nonoverlapping" ]
2946
+ // Copy is "untyped".
2946
2947
#[ requires( !count. overflowing_mul( size_of:: <T >( ) ) . 1
2947
- && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src, count) )
2948
- && ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst, count) ) ) ]
2949
- #[ requires( src. addr( ) != dst. addr( ) || core:: mem:: size_of:: <T >( ) == 0 ) ]
2950
- #[ requires( ( src. addr( ) >= dst. addr( ) + core:: mem:: size_of:: <T >( ) ) || ( dst. addr( ) >= src. addr( ) + core:: mem:: size_of:: <T >( ) ) ) ]
2948
+ && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src as * const crate :: mem:: MaybeUninit <u8 >, count * size_of:: <T >( ) ) )
2949
+ && ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst as * mut u8 , count * size_of:: <T >( ) ) ) ) ]
2950
+ #[ requires( ub_checks:: is_nonoverlapping( src as * const ( ) , dst as * const ( ) , size_of:: <T >( ) , count) ) ]
2951
2951
// TODO: Modifies doesn't work with slices today.
2952
2952
// https://github.com/model-checking/kani/pull/3295
2953
2953
// #[cfg_attr(kani, kani::modifies(crate::ptr::slice_from_raw_parts(dst, count)))]
@@ -3055,8 +3055,8 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
3055
3055
#[ rustc_diagnostic_item = "ptr_copy" ]
3056
3056
// FIXME: How to verify safety for types that do not implement Copy and count > 1??
3057
3057
#[ requires( !count. overflowing_mul( size_of:: <T >( ) ) . 1
3058
- && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src, count) )
3059
- && ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst, count) ) ) ]
3058
+ && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src as * const crate :: mem :: MaybeUninit < u8 > , count * size_of :: < T > ( ) ) )
3059
+ && ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst as * mut u8 , count * size_of :: < T > ( ) ) ) ) ]
3060
3060
// TODO: Modifies doesn't work with slices today.
3061
3061
// https://github.com/model-checking/kani/pull/3295
3062
3062
// #[cfg_attr(kani, kani::modifies(crate::ptr::slice_from_raw_parts(dst, count)))]
0 commit comments