Skip to content

Commit 9884635

Browse files
committed
regex: remove From<regex_syntax::Error> impl
This removes a public `From` impl that automatically converts errors from the regex-syntax crate to a regex::Error. This actually causes regex-syntax to be a public dependency of regex, which was an oversight. We now remove it, which completely breaks any source code coupling between regex and regex-syntax. See #457
1 parent 8e180eb commit 9884635

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

Diff for: src/error.rs

-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use std::fmt;
1212
use std::iter::repeat;
1313

14-
use syntax;
15-
1614
/// An error that occurred during parsing or compiling a regular expression.
1715
#[derive(Clone, PartialEq)]
1816
pub enum Error {
@@ -84,9 +82,3 @@ impl fmt::Debug for Error {
8482
}
8583
}
8684
}
87-
88-
impl From<syntax::Error> for Error {
89-
fn from(err: syntax::Error) -> Error {
90-
Error::Syntax(err.to_string())
91-
}
92-
}

Diff for: src/exec.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ impl ExecBuilder {
228228
.allow_invalid_utf8(!self.only_utf8)
229229
.nest_limit(self.options.nest_limit)
230230
.build();
231-
let expr = parser.parse(pat)?;
231+
let expr = parser
232+
.parse(pat)
233+
.map_err(|e| Error::Syntax(e.to_string()))?;
232234
bytes = bytes || !expr.is_always_utf8();
233235

234236
if !expr.is_anchored_start() && expr.is_any_anchored_start() {

0 commit comments

Comments
 (0)