diff --git a/src/error.rs b/src/error.rs index b068201f6d..fff1969b47 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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 { @@ -84,9 +82,3 @@ impl fmt::Debug for Error { } } } - -impl From for Error { - fn from(err: syntax::Error) -> Error { - Error::Syntax(err.to_string()) - } -} diff --git a/src/exec.rs b/src/exec.rs index 9133a0ddd4..e6079e6c7a 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -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() {