@@ -2727,7 +2727,7 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
2727
2727
#[ requires( ub_checks:: can_dereference( x) && ub_checks:: can_write( x) ) ]
2728
2728
#[ requires( ub_checks:: can_dereference( y) && ub_checks:: can_write( y) ) ]
2729
2729
#[ requires( x. addr( ) != y. addr( ) || core:: mem:: size_of:: <T >( ) == 0 ) ]
2730
- #[ requires( ( x . addr ( ) >= y . addr ( ) + core :: mem :: size_of :: < T > ( ) ) || ( y . addr ( ) >= x . addr ( ) + core :: mem :: size_of:: <T >( ) ) ) ]
2730
+ #[ requires( ub_checks :: is_nonoverlapping ( x as * const ( ) , x as * const ( ) , size_of:: <T >( ) , 1 ) ) ]
2731
2731
pub const unsafe fn typed_swap < T > ( x : * mut T , y : * mut T ) {
2732
2732
// SAFETY: The caller provided single non-overlapping items behind
2733
2733
// pointers, so swapping them with `count: 1` is fine.
@@ -2956,11 +2956,11 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *cons
2956
2956
#[ inline( always) ]
2957
2957
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
2958
2958
#[ rustc_diagnostic_item = "ptr_copy_nonoverlapping" ]
2959
+ // Copy is "untyped".
2959
2960
#[ requires( !count. overflowing_mul( size_of:: <T >( ) ) . 1
2960
- && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src, count) )
2961
+ && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src as * const crate :: mem :: MaybeUninit < T > , count) )
2961
2962
&& ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst, count) ) ) ]
2962
- #[ requires( src. addr( ) != dst. addr( ) || core:: mem:: size_of:: <T >( ) == 0 ) ]
2963
- #[ requires( ( src. addr( ) >= dst. addr( ) + core:: mem:: size_of:: <T >( ) ) || ( dst. addr( ) >= src. addr( ) + core:: mem:: size_of:: <T >( ) ) ) ]
2963
+ #[ requires( ub_checks:: is_nonoverlapping( src as * const ( ) , dst as * const ( ) , size_of:: <T >( ) , count) ) ]
2964
2964
// TODO: Modifies doesn't work with slices today.
2965
2965
// https://github.com/model-checking/kani/pull/3295
2966
2966
// #[cfg_attr(kani, kani::modifies(crate::ptr::slice_from_raw_parts(dst, count)))]
@@ -3068,8 +3068,8 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
3068
3068
#[ rustc_diagnostic_item = "ptr_copy" ]
3069
3069
// FIXME: How to verify safety for types that do not implement Copy and count > 1??
3070
3070
#[ requires( !count. overflowing_mul( size_of:: <T >( ) ) . 1
3071
- && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src, count) )
3072
- && ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst, count) ) ) ]
3071
+ && ub_checks:: can_dereference( core:: ptr:: slice_from_raw_parts( src as * const crate :: mem :: MaybeUninit < T > , count) )
3072
+ && ub_checks:: can_write( core:: ptr:: slice_from_raw_parts_mut( dst, count) ) ) ]
3073
3073
// TODO: Modifies doesn't work with slices today.
3074
3074
// https://github.com/model-checking/kani/pull/3295
3075
3075
// #[cfg_attr(kani, kani::modifies(crate::ptr::slice_from_raw_parts(dst, count)))]
0 commit comments