@@ -301,7 +301,9 @@ impl FusedIterator for Utf8Chunks<'_> {}
301301#[ stable( feature = "utf8_chunks" , since = "1.79.0" ) ]
302302impl fmt:: Debug for Utf8Chunks < ' _ > {
303303 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
304- f. debug_struct ( "Utf8Chunks" ) . field ( "source" , & self . debug ( ) ) . finish ( )
304+ f. debug_struct ( "Utf8Chunks" )
305+ . field ( "source" , & self . debug ( ) )
306+ . finish ( )
305307 }
306308}
307309
@@ -312,14 +314,23 @@ pub mod verify {
312314
313315 #[ kani:: proof]
314316 pub fn check_next ( ) {
315- // TODO: ARR_SIZE can be `std::usize::MAX` with cbmc argument
316- // `--arrays-uf-always`
317- const ARR_SIZE : usize = 1000 ;
318- let mut x: [ u8 ; ARR_SIZE ] = kani:: any ( ) ;
319- let mut xs = kani:: slice:: any_slice_of_array_mut ( & mut x) ;
320- let mut chunks = xs. utf8_chunks ( ) ;
321- unsafe {
322- chunks. next ( ) ;
317+ if kani:: any ( ) {
318+ // TODO: ARR_SIZE can be `std::usize::MAX` with cbmc argument
319+ // `--arrays-uf-always`
320+ const ARR_SIZE : usize = 1000 ;
321+ let mut x: [ u8 ; ARR_SIZE ] = kani:: any ( ) ;
322+ let mut xs = kani:: slice:: any_slice_of_array_mut ( & mut x) ;
323+ let mut chunks = xs. utf8_chunks ( ) ;
324+ unsafe {
325+ chunks. next ( ) ;
326+ }
327+ } else {
328+ let ptr = kani:: any_where :: < usize , _ > ( |val| * val != 0 ) as * const u8 ;
329+ kani:: assume ( ptr. is_aligned ( ) ) ;
330+ unsafe {
331+ let mut chunks = crate :: slice:: from_raw_parts ( ptr, 0 ) . utf8_chunks ( ) ;
332+ chunks. next ( ) ;
333+ }
323334 }
324335 }
325336}
0 commit comments