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() {
1631
1631
assert ! ( !"00abc01234567890123456789abc" . contains( "bcabc" ) ) ;
1632
1632
}
1633
1633
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
+
1634
1646
#[ test]
1635
1647
#[ cfg_attr( miri, ignore) ] // Miri is too slow
1636
1648
fn test_strslice_contains ( ) {
You can’t perform that action at this time.
0 commit comments