File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
use crate :: intrinsics:: const_eval_select;
5
5
#[ cfg( kani) ]
6
+ use crate :: forall;
7
+ #[ cfg( kani) ]
6
8
use crate :: kani;
7
9
8
10
const LO_USIZE : usize = usize:: repeat_u8 ( 0x01 ) ;
@@ -38,7 +40,7 @@ const fn memchr_naive(x: u8, text: &[u8]) -> Option<usize> {
38
40
let mut i = 0 ;
39
41
40
42
// FIXME(const-hack): Replace with `text.iter().pos(|c| *c == x)`.
41
- #[ kani:: loop_invariant( i <= text. len( ) && kani :: forall!( |j in ( 0 , i) | unsafe { * text. as_ptr( ) . wrapping_add( j) } != x) ) ]
43
+ #[ kani:: loop_invariant( i <= text. len( ) && forall!( |j in ( 0 , i) | unsafe { * text. as_ptr( ) . wrapping_add( j) } != x) ) ]
42
44
while i < text. len ( ) {
43
45
if text[ i] == x {
44
46
return Some ( i) ;
@@ -82,7 +84,7 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
82
84
// search the body of the text
83
85
let repeated_x = usize :: repeat_u8( x) ;
84
86
#[ kani:: loop_invariant( len >= 2 * USIZE_BYTES && offset <= len &&
85
- kani :: forall!( |j in ( 0 , offset) | unsafe { * text. as_ptr( ) . wrapping_add( j) } != x) ) ]
87
+ forall!( |j in ( 0 , offset) | unsafe { * text. as_ptr( ) . wrapping_add( j) } != x) ) ]
86
88
while offset <= len - 2 * USIZE_BYTES {
87
89
// SAFETY: the while's predicate guarantees a distance of at least 2 * usize_bytes
88
90
// between the offset and the end of the slice.
You can’t perform that action at this time.
0 commit comments