Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated uses of Error::description. #208

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 3 additions & 52 deletions src/de/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl fmt::Display for Error {
match *self {
Error::IoError(ref s) => write!(f, "{}", s),
Error::Message(ref s) => write!(f, "{}", s),
Error::Parser(_, pos) => write!(f, "{}: {}", pos, self.description()),
Error::Parser(_, pos) => write!(f, "{}: {}", pos, self),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now infinitely recursive!

}
}
}
Expand All @@ -73,56 +73,7 @@ impl de::Error for Error {
}
}

impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::IoError(ref s) => s,
Error::Message(ref e) => e,
Error::Parser(ref kind, _) => match *kind {
ParseError::Base64Error(ref e) => e.description(),
ParseError::Eof => "Unexpected end of file",
ParseError::ExpectedArray => "Expected array",
ParseError::ExpectedArrayEnd => "Expected end of array",
ParseError::ExpectedAttribute => "Expected an enable attribute",
ParseError::ExpectedAttributeEnd => {
"Expected closing `)` and `]` after the attribute"
}
ParseError::ExpectedBoolean => "Expected boolean",
ParseError::ExpectedComma => "Expected comma",
ParseError::ExpectedEnum => "Expected enum",
ParseError::ExpectedChar => "Expected char",
ParseError::ExpectedFloat => "Expected float",
ParseError::ExpectedInteger => "Expected integer",
ParseError::ExpectedOption => "Expected option",
ParseError::ExpectedOptionEnd => "Expected end of option",
ParseError::ExpectedMap => "Expected map",
ParseError::ExpectedMapColon => "Expected colon",
ParseError::ExpectedMapEnd => "Expected end of map",
ParseError::ExpectedStruct => "Expected struct",
ParseError::ExpectedStructEnd => "Expected end of struct",
ParseError::ExpectedUnit => "Expected unit",
ParseError::ExpectedStructName => "Expected struct name",
ParseError::ExpectedString => "Expected string",
ParseError::ExpectedStringEnd => "Expected string end",
ParseError::ExpectedIdentifier => "Expected identifier",

ParseError::InvalidEscape(_) => "Invalid escape sequence",

ParseError::IntegerOutOfBounds => "Integer is out of bounds",

ParseError::NoSuchExtension(_) => "No such RON extension",

ParseError::Utf8Error(ref e) => e.description(),
ParseError::UnclosedBlockComment => "Unclosed block comment",
ParseError::UnderscoreAtBeginning => "Found underscore at the beginning",
ParseError::UnexpectedByte(_) => "Unexpected byte",
ParseError::TrailingCharacters => "Non-whitespace trailing characters",

ParseError::__NonExhaustive => unimplemented!(),
},
}
}
}
impl StdError for Error {}

impl From<Utf8Error> for ParseError {
fn from(e: Utf8Error) -> Self {
Expand All @@ -144,6 +95,6 @@ impl From<Utf8Error> for Error {

impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
Error::IoError(e.description().to_string())
Error::IoError(e.to_string())
}
}