about summary refs log tree commit diff
path: root/src/libserialize
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2019-11-30 20:01:48 -0800
committerDavid Tolnay <dtolnay@gmail.com>2019-12-24 22:39:49 -0800
commit4646a88b7a1e68326d092b9cbbbbdd616a51077f (patch)
treee22c490b7e63a021218a48af92bc08a6483c6a9e /src/libserialize
parentc5a2a9a99c3973f77d7c86acb8ff7039c3d9c703 (diff)
Deprecate Error::description for real
`description` has been documented as soft-deprecated since 1.27.0 (17
months ago). There is no longer any reason to call it or implement it.

This commit:

- adds #[rustc_deprecated(since = "1.41.0")] to Error::description;

- moves description (and cause, which is also deprecated) below the
  source and backtrace methods in the Error trait;

- reduces documentation of description and cause to take up much less
  vertical real estate in rustdocs, while preserving the example that
  shows how to render errors without needing to call description;

- removes the description function of all *currently unstable* Error
  impls in the standard library;

- marks #[allow(deprecated)] the description function of all *stable*
  Error impls in the standard library;

- replaces miscellaneous uses of description in example code and the
  compiler.
Diffstat (limited to 'src/libserialize')
-rw-r--r--src/libserialize/hex.rs9
-rw-r--r--src/libserialize/json.rs12
2 files changed, 3 insertions, 18 deletions
diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs
index a2a5a3cb59c..cfb165a3d43 100644
--- a/src/libserialize/hex.rs
+++ b/src/libserialize/hex.rs
@@ -68,14 +68,7 @@ impl fmt::Display for FromHexError {
     }
 }
 
-impl error::Error for FromHexError {
-    fn description(&self) -> &str {
-        match *self {
-            InvalidHexCharacter(..) => "invalid character",
-            InvalidHexLength => "invalid length",
-        }
-    }
-}
+impl error::Error for FromHexError {}
 
 impl FromHex for str {
     /// Converts any hexadecimal encoded string (literal, `@`, `&`, or `~`)
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index b1ad0e853a3..1f9d43cb930 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -345,11 +345,7 @@ impl fmt::Display for DecoderError {
     }
 }
 
-impl std::error::Error for DecoderError {
-    fn description(&self) -> &str {
-        "decoder error"
-    }
-}
+impl std::error::Error for DecoderError {}
 
 impl fmt::Display for EncoderError {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -358,11 +354,7 @@ impl fmt::Display for EncoderError {
     }
 }
 
-impl std::error::Error for EncoderError {
-    fn description(&self) -> &str {
-        "encoder error"
-    }
-}
+impl std::error::Error for EncoderError {}
 
 impl From<fmt::Error> for EncoderError {
     /// Converts a [`fmt::Error`] into `EncoderError`