@@ -1959,10 +1959,10 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
19591959 unsafe {
19601960 let ( mut px, mut py) = ( x. as_ptr ( ) , y. as_ptr ( ) ) ;
19611961 let ( pxend, pyend) = ( px. add ( x. len ( ) - 4 ) , py. add ( y. len ( ) - 4 ) ) ;
1962- #[ cfg_attr ( kani , kani :: loop_invariant( same_allocation( x. as_ptr( ) , px) && same_allocation( y. as_ptr( ) , py)
1962+ #[ safety :: loop_invariant( same_allocation( x. as_ptr( ) , px) && same_allocation( y. as_ptr( ) , py)
19631963 && px as isize >= x. as_ptr( ) as isize
19641964 && py as isize >= y. as_ptr( ) as isize
1965- && px as isize - x. as_ptr( ) as isize == ( py as isize - y. as_ptr( ) as isize ) ) ) ]
1965+ && px as isize - x. as_ptr( ) as isize == ( py as isize - y. as_ptr( ) as isize ) ) ]
19661966 while px < pxend {
19671967 let vx = ( px as * const u32 ) . read_unaligned ( ) ;
19681968 let vy = ( py as * const u32 ) . read_unaligned ( ) ;
@@ -1983,30 +1983,17 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
19831983pub mod verify {
19841984 use super :: * ;
19851985
1986- // Copied from https://github.com/model-checking/kani/blob/main/library/kani/src/slice.rs
1987- // should be removed when these functions are moved to `kani_core`
1988- pub fn any_slice_of_array < T , const LENGTH : usize > ( arr : & [ T ; LENGTH ] ) -> & [ T ] {
1989- let ( from, to) = any_range :: < LENGTH > ( ) ;
1990- & arr[ from..to]
1991- }
1992-
1993- fn any_range < const LENGTH : usize > ( ) -> ( usize , usize ) {
1994- let from: usize = kani:: any ( ) ;
1995- let to: usize = kani:: any ( ) ;
1996- kani:: assume ( to <= LENGTH ) ;
1997- kani:: assume ( from <= to) ;
1998- ( from, to)
1999- }
2000-
20011986 #[ cfg( all( kani, target_arch = "x86_64" ) ) ] // only called on x86
20021987 #[ kani:: proof]
20031988 #[ kani:: unwind( 4 ) ]
20041989 pub fn check_small_slice_eq ( ) {
1990+ // ARR_SIZE can `std::usize::MAX` with cbmc argument
1991+ // `--arrays-uf-always`
20051992 const ARR_SIZE : usize = 1000 ;
20061993 let x: [ u8 ; ARR_SIZE ] = kani:: any ( ) ;
20071994 let y: [ u8 ; ARR_SIZE ] = kani:: any ( ) ;
2008- let xs = any_slice_of_array ( & x) ;
2009- let ys = any_slice_of_array ( & y) ;
1995+ let xs = kani :: slice :: any_slice_of_array ( & x) ;
1996+ let ys = kani :: slice :: any_slice_of_array ( & y) ;
20101997 kani:: assume ( xs. len ( ) == ys. len ( ) ) ;
20111998 unsafe {
20121999 small_slice_eq ( xs, ys) ;
0 commit comments