Remove LexError from public API
diff --git a/src/error.rs b/src/error.rs
index bd33775..72a25e8 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,5 +1,3 @@
-use proc_macro;
-use proc_macro2;
use std::error::Error;
use cursor::Cursor;
use std::fmt::{self, Display};
@@ -32,18 +30,6 @@
}
}
-impl From<proc_macro2::LexError> for ParseError {
- fn from(_: proc_macro2::LexError) -> ParseError {
- ParseError(Some("error while lexing input string".to_owned()))
- }
-}
-
-impl From<proc_macro::LexError> for ParseError {
- fn from(_: proc_macro::LexError) -> ParseError {
- ParseError(Some("error while lexing input string".to_owned()))
- }
-}
-
impl ParseError {
// For syn use only. Not public API.
#[doc(hidden)]
diff --git a/src/lib.rs b/src/lib.rs
index 2d2ad97..d138dd6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -256,7 +256,10 @@
/// ```
#[cfg(feature = "parsing")]
pub fn parse_str<T: Synom>(s: &str) -> Result<T, ParseError> {
- _parse(s.parse()?)
+ match s.parse() {
+ Ok(tts) => _parse(tts),
+ Err(_) => Err(ParseError::new("error while lexing input string")),
+ }
}
// FIXME the name parse_file makes it sound like you might pass in a path to a