Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions src/decoder/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ impl fmt::Display for DecoderError {
impl error::Error for DecoderError {
fn description(&self) -> &str {
match *self {
DecoderError::IoError(ref inner) => inner.description(),
DecoderError::FromUtf8Error(ref inner) => inner.description(),
DecoderError::IoError(ref inner) =>
{
#[allow(deprecated)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error::description has been deprecated in Rust 1.42, and clippy suggests using to_string(), but unfortunately we aren't able to here since we're returning a reference, and the newly-allocated string returned by to_string() won't live long enough. We probably will want to get rid of our own description implementations before 1.0, but for now, I've just annotated each of these calls to suppress the deprecation warning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you file a ticket for dropping the description implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inner.description()
}
DecoderError::FromUtf8Error(ref inner) =>
{
#[allow(deprecated)]
inner.description()
}
DecoderError::UnrecognizedElementType(_) => "unrecognized element type",
DecoderError::InvalidArrayKey(..) => "invalid array key",
DecoderError::ExpectedField(_) => "expected a field",
Expand Down
6 changes: 5 additions & 1 deletion src/encoder/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ impl fmt::Display for EncoderError {
impl error::Error for EncoderError {
fn description(&self) -> &str {
match *self {
EncoderError::IoError(ref inner) => inner.description(),
EncoderError::IoError(ref inner) =>
{
#[allow(deprecated)]
inner.description()
}
EncoderError::InvalidMapKeyType(_) => "Invalid map key type",
EncoderError::Unknown(ref inner) => inner,
EncoderError::UnsupportedUnsignedType => "BSON does not support unsigned type",
Expand Down
12 changes: 10 additions & 2 deletions src/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::ArgumentError(ref inner) => &inner,
Error::FromHexError(ref inner) => inner.description(),
Error::IoError(ref inner) => inner.description(),
Error::FromHexError(ref inner) =>
{
#[allow(deprecated)]
inner.description()
}
Error::IoError(ref inner) =>
{
#[allow(deprecated)]
inner.description()
}
Error::HostnameError => "Failed to retrieve hostname for OID generation.",
}
}
Expand Down