Skip to content

Commit c706552

Browse files
committed
api: make Regex UnwindSafe again
This commit fixes a regression introduced in 1.1.3 where Regex was no longer UnwindSafe. The underlying reason is that the new AhoCorasick type in aho-corasick 0.7 was not UnwindSafe. This has been fixed in aho-corasick 0.7.4, so all we need to do to fix it is to increase the minimum aho-corasick version, which we do here. We also add an oibits test that ensures this particular regression can't happen again. (Along with testing Send and Sync, which surprisingly did not have seem to have tests before this.) Fixes #568
1 parent 89074f8 commit c706552

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
1.1.4 (2019-03-31)
2+
==================
3+
This release fixes a backwards compatibility regression where Regex was no
4+
longer UnwindSafe. This was caused by the upgrade to aho-corasick 0.7, whose
5+
AhoCorasick type was itself not UnwindSafe. This has been fixed in aho-corasick
6+
0.7.4, which we now require.
7+
8+
Bug fixes:
9+
10+
* [BUG #568](https://github.com/rust-lang/regex/pull/568):
11+
Fix an API regression where Regex was no longer UnwindSafe.
12+
13+
114
1.1.3 (2019-03-30)
215
==================
316
This releases fixes a few bugs and adds a performance improvement when a regex

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ members = [
2626

2727
[dependencies]
2828
# For very fast prefix literal matching.
29-
aho-corasick = "0.7.1"
29+
aho-corasick = "0.7.3"
3030
# For skipping along search text quickly when a leading byte is known.
3131
memchr = "2.0.2"
3232
# For managing regex caches quickly across multiple threads.

tests/test_default.rs

+34
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,37 @@ fn disallow_octal() {
8585
fn allow_octal() {
8686
assert!(regex::RegexBuilder::new(r"\0").octal(true).build().is_ok());
8787
}
88+
89+
#[test]
90+
fn oibits() {
91+
use std::panic::UnwindSafe;
92+
use regex::{Regex, RegexBuilder};
93+
use regex::bytes;
94+
95+
fn assert_send<T: Send>() {}
96+
fn assert_sync<T: Sync>() {}
97+
fn assert_unwind_safe<T: UnwindSafe>() {}
98+
99+
assert_send::<Regex>();
100+
assert_sync::<Regex>();
101+
assert_unwind_safe::<Regex>();
102+
assert_send::<RegexBuilder>();
103+
assert_sync::<RegexBuilder>();
104+
assert_unwind_safe::<RegexBuilder>();
105+
106+
assert_send::<bytes::Regex>();
107+
assert_sync::<bytes::Regex>();
108+
assert_unwind_safe::<bytes::Regex>();
109+
assert_send::<bytes::RegexBuilder>();
110+
assert_sync::<bytes::RegexBuilder>();
111+
assert_unwind_safe::<bytes::RegexBuilder>();
112+
}
113+
114+
// See: https://github.com/rust-lang/regex/issues/568
115+
#[test]
116+
fn oibits_regression() {
117+
use std::panic;
118+
use regex::Regex;
119+
120+
let _ = panic::catch_unwind(|| Regex::new("a").unwrap());
121+
}

0 commit comments

Comments
 (0)