Commit 8f5d947
committed
automata: make behavior more consistent when
Specifically, when used with `meta::Regex`. Before this PR, if callers
built a `meta::Regex` with `WhichCaptures::None`, then it was possible
for `find` to _sometimes_ return `Some` and _sometimes_ return `None`,
just based on the sequence of previous search calls.
In particular, when `WhichCaptures::None` is used, some regex engines
(like the `PikeVM`) cannot report match offsets while some (like the
lazy DFA) can. This meant that if the meta regex engine _happened_ to
select the lazy DFA for a `Regex::find` call, then it would return
`Some`. But if it _happened_ to select the Pike VM, then it would return
`None`. Since engine selection can be influenced by the haystack itself,
this leads to the behavior of `find` being tied to the contents of the
haystack.
Instead, what we should do is make it so anything that returns match
offsets on a `meta::Regex` will always return `None` when
`WhichCaptures::None` is used, _even_ if `Regex::is_match` returns
`true`.
(Yes, this is a weird option and it's crazy that `Regex::is_match` can
return `true` while `Regex::find` can return `None`. This was already
true before this PR and is a result of a very low level option that
optimizes for memory usage in specific circumstances. This sort of
whacky behavior can't be observed in the `regex` crate API. Only in
`regex-automata`.)WhichCaptures::None is used1 parent 977feeb commit 8f5d947
2 files changed
+86
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
920 | | - | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
921 | 923 | | |
922 | 924 | | |
923 | 925 | | |
| |||
973 | 975 | | |
974 | 976 | | |
975 | 977 | | |
976 | | - | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
977 | 981 | | |
978 | 982 | | |
979 | 983 | | |
| |||
1128 | 1132 | | |
1129 | 1133 | | |
1130 | 1134 | | |
1131 | | - | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1132 | 1138 | | |
1133 | 1139 | | |
1134 | 1140 | | |
| |||
1242 | 1248 | | |
1243 | 1249 | | |
1244 | 1250 | | |
1245 | | - | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1246 | 1254 | | |
1247 | 1255 | | |
1248 | 1256 | | |
| |||
1284 | 1292 | | |
1285 | 1293 | | |
1286 | 1294 | | |
1287 | | - | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
1288 | 1298 | | |
1289 | 1299 | | |
1290 | 1300 | | |
| |||
1437 | 1447 | | |
1438 | 1448 | | |
1439 | 1449 | | |
1440 | | - | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
1441 | 1453 | | |
1442 | 1454 | | |
1443 | 1455 | | |
| |||
1982 | 1994 | | |
1983 | 1995 | | |
1984 | 1996 | | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
1985 | 2010 | | |
1986 | 2011 | | |
1987 | 2012 | | |
| |||
2645 | 2670 | | |
2646 | 2671 | | |
2647 | 2672 | | |
2648 | | - | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
2649 | 2679 | | |
2650 | 2680 | | |
2651 | 2681 | | |
| |||
2694 | 2724 | | |
2695 | 2725 | | |
2696 | 2726 | | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
2697 | 2754 | | |
2698 | 2755 | | |
2699 | 2756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
566 | 588 | | |
567 | 589 | | |
568 | 590 | | |
| |||
0 commit comments