Issue #673: std::regex: RE2 dialect; typed by its engine; a known pattern compiled while building and run by std’s code specialised for it; run-time patterns on regex-automata

Open and answer this issue on GitHub.

ready · opened 2026-10-18 · updated 2026-10-28 · 0 comments

What is missing

There was no regex in std. Text work used starts_with, split or counting loops; a grammar cannot stand in, because it is a PEG (ordered choice, possessive repetition: a*a never matches as a rule, and does as a regular expression).

History

Decision

ADR-regex-1 (why, rejected alternatives), ADR-specialization-1 (the mechanism S1/S2 are written on); specification Part I 2.6. In short:

To build

  1. Run-time patterns. Built (0.0.1257): regex::Regex[regex::Dynamic], regex::Engine, regex::dynamic, is_match, find, find_all, captures (group, named), replace_all, split; a match is a text::Match with m.text() only. Not yet: regex::Any; positions (m.start, m.end, from:).
  2. Positions, when ADR-374 is built: m.start, m.end as text::Pos, from: on find and captures, groups’ positions. Tests: a multibyte text, a search from the end of a previous match.
  3. regex::compile on the floor: needs ADR-333 D3 (a comptime parameter) and ADR-specialization-1 D7 (a result type computed from it). At first it gives Regex[regex::Dynamic] and checks the pattern while building (NK1244, the engine’s message). regex::compile with a run-time value refused, the help naming regex::dynamic.
  4. S2 as a table: regex::Dfa, forward and reverse dense DFA laid down for the target, a constant entry for the type, a crate under crates/unsafe opening them with from_bytes_unchecked; the report (D9) in --comptime.
  5. Differential test and benchmark: every engine that accepts a pattern against regex::dynamic (D5.1), a fuzz driver in Nikaia (a finding if std lacks what it needs); benches/regex/ with instruction counts against a tuned Rust program on the crate, same output first; it sets the default limits.
  6. regex::Any, when there is a second engine.
  7. S2 as code, S1, S0, on ADR-specialization-1 once it is built (#906); each measured against step 5.
  8. S3, S4, S5, each its own package, each after a measurement says it pays.
  9. Guide section; rewrite demoted in the site-issues prototype with it. The commit that builds the last step says Fixes #673.

Back to Open Issues