@@ -1887,7 +1887,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
1887
1887
/// # Safety
1888
1888
///
1889
1889
/// Both slices must have the same length.
1890
- #[ cfg( all( target_arch = "x86_64" , target_feature = "sse2" ) ) ] // only called on x86
1890
+ #[ cfg( all( target_arch = "x86_64" , any ( kani , target_feature = "sse2" ) ) ) ] // only called on x86
1891
1891
#[ inline]
1892
1892
#[ requires( x. len( ) == y. len( ) ) ]
1893
1893
unsafe fn small_slice_eq ( x : & [ u8 ] , y : & [ u8 ] ) -> bool {
@@ -1958,17 +1958,13 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
1958
1958
pub mod verify {
1959
1959
use super :: * ;
1960
1960
1961
+ // Copied from https://github.com/model-checking/kani/blob/main/library/kani/src/slice.rs
1962
+ // should be removed when these functions are moved to `kani_core`
1961
1963
pub fn any_slice_of_array < T , const LENGTH : usize > ( arr : & [ T ; LENGTH ] ) -> & [ T ] {
1962
1964
let ( from, to) = any_range :: < LENGTH > ( ) ;
1963
1965
& arr[ from..to]
1964
1966
}
1965
1967
1966
- /// A mutable version of the previous function
1967
- pub fn any_slice_of_array_mut < T , const LENGTH : usize > ( arr : & mut [ T ; LENGTH ] ) -> & mut [ T ] {
1968
- let ( from, to) = any_range :: < LENGTH > ( ) ;
1969
- & mut arr[ from..to]
1970
- }
1971
-
1972
1968
fn any_range < const LENGTH : usize > ( ) -> ( usize , usize ) {
1973
1969
let from: usize = kani:: any ( ) ;
1974
1970
let to: usize = kani:: any ( ) ;
@@ -1977,14 +1973,16 @@ pub mod verify {
1977
1973
( from, to)
1978
1974
}
1979
1975
1980
- #[ cfg( all( target_arch = "x86_64" , target_feature = "sse2 " ) ) ] // only called on x86
1976
+ #[ cfg( all( kani , target_arch = "x86_64 " ) ) ] // only called on x86
1981
1977
#[ kani:: proof]
1978
+ #[ kani:: unwind( 4 ) ]
1982
1979
pub fn check_small_slice_eq ( ) {
1983
1980
const ARR_SIZE : usize = 1000 ;
1984
1981
let x: [ u8 ; ARR_SIZE ] = kani:: any ( ) ;
1985
1982
let y: [ u8 ; ARR_SIZE ] = kani:: any ( ) ;
1986
1983
let xs = any_slice_of_array ( & x) ;
1987
1984
let ys = any_slice_of_array ( & y) ;
1985
+ kani:: assume ( xs. len ( ) == ys. len ( ) ) ;
1988
1986
unsafe {
1989
1987
small_slice_eq ( xs, ys) ;
1990
1988
}
0 commit comments