Skip to content

Commit 51312ea

Browse files
author
Martijn Groeneveldt
committed
Add best effort error descriptions
1 parent a1f9e6d commit 51312ea

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/parser.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ impl<'i> fmt::Display for BasicParseError<'i> {
8484
}
8585
}
8686

87-
impl<'i> Error for BasicParseError<'i> {}
87+
impl<'i> Error for BasicParseError<'i> {
88+
fn description(&self) -> &str {
89+
"A BasicParseError has occurred, please use the Display trait to determine it's kind"
90+
}
91+
}
8892

8993
impl<'i, T> From<BasicParseError<'i>> for ParseError<'i, T> {
9094
#[inline]
@@ -192,7 +196,14 @@ where
192196
}
193197
}
194198

195-
impl<'i, T> Error for ParseError<'i, T> where T: Error {}
199+
impl<'i, T> Error for ParseError<'i, T>
200+
where
201+
T: Error,
202+
{
203+
fn description(&self) -> &str {
204+
"A ParseError has occurred, please use the Display trait to determine it's kind"
205+
}
206+
}
196207

197208
/// The owned input for a parser.
198209
pub struct ParserInput<'i> {

src/rules_and_declarations.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ where
268268
let start = self.input.state();
269269
// FIXME: remove intermediate variable when lifetimes are non-lexical
270270
let ident = match self.input.next_including_whitespace_and_comments() {
271-
Ok(&Token::WhiteSpace(_)) | Ok(&Token::Comment(_)) | Ok(&Token::Semicolon) => continue,
271+
Ok(&Token::WhiteSpace(_)) | Ok(&Token::Comment(_)) | Ok(&Token::Semicolon) => {
272+
continue
273+
}
272274
Ok(&Token::Ident(ref name)) => Ok(Ok(name.clone())),
273275
Ok(&Token::AtKeyword(ref name)) => Ok(Err(name.clone())),
274276
Ok(token) => Err(token.clone()),

0 commit comments

Comments
 (0)