We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66ccf36 commit d576a9bCopy full SHA for d576a9b
library/alloc/tests/str.rs
@@ -1631,6 +1631,18 @@ fn strslice_issue_16878() {
1631
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
1632
}
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
+
1646
#[test]
1647
#[cfg_attr(miri, ignore)] // Miri is too slow
1648
fn test_strslice_contains() {
0 commit comments