Skip to content

Commit

Permalink
regex: remove From<regex_syntax::Error> impl
Browse files Browse the repository at this point in the history
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 rust-lang#457
  • Loading branch information
BurntSushi committed Apr 28, 2018
1 parent 1843da6 commit 8468c28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use std::fmt;
use std::iter::repeat;

use syntax;

/// An error that occurred during parsing or compiling a regular expression.
#[derive(Clone, PartialEq)]
pub enum Error {
Expand Down Expand Up @@ -84,9 +82,3 @@ impl fmt::Debug for Error {
}
}
}

impl From<syntax::Error> for Error {
fn from(err: syntax::Error) -> Error {
Error::Syntax(err.to_string())
}
}
4 changes: 3 additions & 1 deletion src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ impl ExecBuilder {
.allow_invalid_utf8(!self.only_utf8)
.nest_limit(self.options.nest_limit)
.build();
let expr = parser.parse(pat)?;
let expr = parser
.parse(pat)
.map_err(|e| Error::Syntax(e.to_string()))?;
bytes = bytes || !expr.is_always_utf8();

if !expr.is_anchored_start() && expr.is_any_anchored_start() {
Expand Down

0 comments on commit 8468c28

Please sign in to comment.