File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1631,6 +1631,18 @@ fn strslice_issue_16878() {
16311631 assert ! ( !"00abc01234567890123456789abc" . contains( "bcabc" ) ) ;
16321632}
16331633
1634+ #[ test]
1635+ fn strslice_issue_104726 ( ) {
1636+ // Edge-case in the simd_contains impl.
1637+ // The first and last byte are the same so it backtracks by one byte
1638+ // which aligns with the end of the string. Previously incorrect offset calculations
1639+ // lead to out-of-bounds slicing.
1640+ #[ rustfmt:: skip]
1641+ let needle = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaba" ;
1642+ let haystack = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab" ;
1643+ assert ! ( !haystack. contains( needle) ) ;
1644+ }
1645+
16341646#[ test]
16351647#[ cfg_attr( miri, ignore) ] // Miri is too slow
16361648fn test_strslice_contains ( ) {
You can’t perform that action at this time.
0 commit comments