11[package ]
22name = " regex"
33version = " 1.8.1" # :version
4- authors = [" The Rust Project Developers" ]
4+ authors = [
" The Rust Project Developers" , " Andrew Gallant <[email protected] > " ]
55license = " MIT OR Apache-2.0"
66readme = " README.md"
77repository = " https://github.com/rust-lang/regex"
@@ -19,7 +19,12 @@ rust-version = "1.60.0"
1919
2020[workspace ]
2121members = [
22- " bench" , " regex-capi" , " regex-syntax" ,
22+ " bench" ,
23+ " regex-automata" ,
24+ " regex-capi" ,
25+ " regex-cli" ,
26+ " regex-syntax" ,
27+ " regex-test" ,
2328]
2429
2530[lib ]
@@ -42,27 +47,53 @@ default = ["std", "perf", "unicode", "regex-syntax/default"]
4247# to compile without std, and instead just rely on 'core' and 'alloc' (for
4348# example). Currently, this isn't supported, and removing the 'std' feature
4449# will prevent regex from compiling.
45- std = []
50+ std = [
51+ " aho-corasick?/std" ,
52+ " memchr?/std" ,
53+ " regex-automata/std" ,
54+ " regex-syntax/std" ,
55+ ]
4656# The 'use_std' feature is DEPRECATED. It will be removed in regex 2. Until
4757# then, it is an alias for the 'std' feature.
4858use_std = [" std" ]
4959
5060
5161# PERFORMANCE FEATURES
5262
53- # Enables all performance features.
54- perf = [" perf-cache" , " perf-dfa" , " perf-inline" , " perf-literal" ]
63+ # Enables all default performance features. Note that this specifically does
64+ # not include perf-dfa-full, because it leads to higher compile times and
65+ # bigger binaries, and the runtime performance improvement is not obviously
66+ # worth it.
67+ perf = [
68+ " perf-cache" ,
69+ " perf-dfa" ,
70+ " perf-onepass" ,
71+ " perf-backtrack" ,
72+ " perf-inline" ,
73+ " perf-literal" ,
74+ ]
5575# Enables fast caching. (If disabled, caching is still used, but is slower.)
5676# Currently, this feature has no effect. It used to remove the thread_local
5777# dependency and use a slower internal cache, but now the default cache has
5878# been improved and thread_local is no longer a dependency at all.
5979perf-cache = []
6080# Enables use of a lazy DFA when possible.
61- perf-dfa = []
81+ perf-dfa = [" regex-automata/hybrid" ]
82+ # Enables use of a fully compiled DFA when possible.
83+ perf-dfa-full = [" regex-automata/dfa-build" , " regex-automata/dfa-search" ]
84+ # Enables use of the one-pass regex matcher, which speeds up capture searches
85+ # even beyond the backtracker.
86+ perf-onepass = [" regex-automata/dfa-onepass" ]
87+ # Enables use of a bounded backtracker, which speeds up capture searches.
88+ perf-backtrack = [" regex-automata/nfa-backtrack" ]
6289# Enables aggressive use of inlining.
63- perf-inline = []
90+ perf-inline = [" regex-automata/perf-inline " ]
6491# Enables literal optimizations.
65- perf-literal = [" aho-corasick" , " memchr" ]
92+ perf-literal = [
93+ " dep:aho-corasick" ,
94+ " dep:memchr" ,
95+ " regex-automata/perf-literal" ,
96+ ]
6697
6798
6899# UNICODE DATA FEATURES
@@ -76,22 +107,45 @@ unicode = [
76107 " unicode-perl" ,
77108 " unicode-script" ,
78109 " unicode-segment" ,
110+ " regex-automata/unicode" ,
79111 " regex-syntax/unicode" ,
80112]
81113# Enables use of the `Age` property, e.g., `\p{Age:3.0}`.
82- unicode-age = [" regex-syntax/unicode-age" ]
114+ unicode-age = [
115+ " regex-automata/unicode-age" ,
116+ " regex-syntax/unicode-age" ,
117+ ]
83118# Enables use of a smattering of boolean properties, e.g., `\p{Emoji}`.
84- unicode-bool = [" regex-syntax/unicode-bool" ]
119+ unicode-bool = [
120+ " regex-automata/unicode-bool" ,
121+ " regex-syntax/unicode-bool" ,
122+ ]
85123# Enables Unicode-aware case insensitive matching, e.g., `(?i)β`.
86- unicode-case = [" regex-syntax/unicode-case" ]
124+ unicode-case = [
125+ " regex-automata/unicode-case" ,
126+ " regex-syntax/unicode-case" ,
127+ ]
87128# Enables Unicode general categories, e.g., `\p{Letter}` or `\pL`.
88- unicode-gencat = [" regex-syntax/unicode-gencat" ]
129+ unicode-gencat = [
130+ " regex-automata/unicode-gencat" ,
131+ " regex-syntax/unicode-gencat" ,
132+ ]
89133# Enables Unicode-aware Perl classes corresponding to `\w`, `\s` and `\d`.
90- unicode-perl = [" regex-syntax/unicode-perl" ]
134+ unicode-perl = [
135+ " regex-automata/unicode-perl" ,
136+ " regex-automata/unicode-word-boundary" ,
137+ " regex-syntax/unicode-perl" ,
138+ ]
91139# Enables Unicode scripts and script extensions, e.g., `\p{Greek}`.
92- unicode-script = [" regex-syntax/unicode-script" ]
140+ unicode-script = [
141+ " regex-automata/unicode-script" ,
142+ " regex-syntax/unicode-script" ,
143+ ]
93144# Enables Unicode segmentation properties, e.g., `\p{gcb=Extend}`.
94- unicode-segment = [" regex-syntax/unicode-segment" ]
145+ unicode-segment = [
146+ " regex-automata/unicode-segment" ,
147+ " regex-syntax/unicode-segment" ,
148+ ]
95149
96150
97151# UNSTABLE FEATURES (requires Rust nightly)
@@ -121,6 +175,13 @@ path = "regex-syntax"
121175version = " 0.7.1"
122176default-features = false
123177
178+ # For the actual regex engines.
179+ [dependencies .regex-automata ]
180+ path = " regex-automata"
181+ version = " 0.3.0"
182+ default-features = false
183+ features = [" alloc" , " syntax" , " meta" , " nfa-pikevm" ]
184+
124185[dev-dependencies ]
125186# For examples.
126187lazy_static = " 1"
@@ -129,10 +190,39 @@ quickcheck = { version = "1.0.3", default-features = false }
129190# For generating random test data.
130191rand = { version = " 0.8.3" , default-features = false , features = [" getrandom" , " small_rng" ] }
131192# To check README's example
132- # TODO: Re-enable this once the MSRV is 1.43 or greater.
133- # See: https://github.com/rust-lang/regex/issues/684
134- # See: https://github.com/rust-lang/regex/issues/685
135- # doc-comment = "0.3"
193+ doc-comment = " 0.3"
194+ # For easy error handling in integration tests.
195+ anyhow = " 1.0.69"
196+ # A library for testing regex engines.
197+ regex-test = { path = " regex-test" , version = " 0.1.0" }
198+
199+ [dev-dependencies .env_logger ]
200+ # Note that this is currently using an older version because of the dependency
201+ # tree explosion that happened in 0.10.
202+ version = " 0.9.3"
203+ default-features = false
204+ features = [" atty" , " humantime" , " termcolor" ]
205+
206+ # This test suite reads a whole boatload of tests from the top-level testdata
207+ # directory, and then runs them against the regex crate API.
208+ #
209+ # regex-automata has its own version of them, and runs them against each
210+ # internal regex engine individually.
211+ #
212+ # This means that if you're seeing a failure in this test suite, you should
213+ # try running regex-automata's tests:
214+ #
215+ # cargo test --manifest-path regex-automata/Cargo.toml --test integration
216+ #
217+ # That *might* give you a more targeted test failure. i.e., "only the
218+ # PikeVM fails this test." Which gives you a narrower place to search. If
219+ # regex-automata's test suite passes, then the bug might be in the integration
220+ # of the regex crate and regex-automata. But generally speaking, a failure
221+ # in this test suite *should* mean there is a corresponding failure in
222+ # regex-automata's test suite.
223+ [[test ]]
224+ path = " newtests/tests.rs"
225+ name = " integration"
136226
137227# Run the test suite on the default behavior of Regex::new.
138228# This includes a mish mash of NFAs and DFAs, which are chosen automatically
@@ -185,11 +275,36 @@ name = "backtrack-bytes"
185275path = " tests/test_crates_regex.rs"
186276name = " crates-regex"
187277
278+ [package .metadata .docs .rs ]
279+ # We want to document all features.
280+ all-features = true
281+ # Since this crate's feature setup is pretty complicated, it is worth opting
282+ # into a nightly unstable option to show the features that need to be enabled
283+ # for public API items. To do that, we set 'docsrs', and when that's enabled,
284+ # we enable the 'doc_auto_cfg' feature.
285+ #
286+ # To test this locally, run:
287+ #
288+ # RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
289+ rustdoc-args = [" --cfg" , " docsrs" ]
290+
188291[profile .release ]
189292debug = true
190293
191294[profile .bench ]
192295debug = true
193296
297+ [profile .dev ]
298+ # Running tests takes too long in debug mode, so we forcefully always build
299+ # with optimizations. Unfortunate, but, ¯\_(ツ)_/¯.
300+ #
301+ # It's counter-intuitive that this needs to be set on dev *and* test, but
302+ # it's because the tests that take a long time to run are run as integration
303+ # tests in a separate crate. The test.opt-level setting won't apply there, so
304+ # we need to set the opt-level across the entire build.
305+ opt-level = 3
306+ debug = true
307+
194308[profile .test ]
309+ opt-level = 3
195310debug = true
0 commit comments