From d93b95490124407b6b3a71dcaf3a4c2f1952e674 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 1 Feb 2021 15:04:07 -0800 Subject: [PATCH] Remove definitions of deprecated `Error::description()`/`cause()`. --- src/error.rs | 44 ++++++++---------------------------------- tests/ed25519_tests.rs | 4 ++-- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/error.rs b/src/error.rs index 23e2ab32a..f1c33e78e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -76,30 +76,15 @@ extern crate std; #[derive(Clone, Copy, Debug, PartialEq)] pub struct Unspecified; -impl Unspecified { - fn description_() -> &'static str { - "ring::error::Unspecified" - } -} - // This is required for the implementation of `std::error::Error`. impl core::fmt::Display for Unspecified { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.write_str(Self::description_()) + f.write_str("ring::error::Unspecified") } } #[cfg(feature = "std")] -impl std::error::Error for Unspecified { - #[inline] - fn cause(&self) -> Option<&dyn std::error::Error> { - None - } - - fn description(&self) -> &str { - Self::description_() - } -} +impl std::error::Error for Unspecified {} impl From for Unspecified { fn from(_: untrusted::EndOfInput) -> Self { @@ -115,10 +100,10 @@ impl From for Unspecified { /// An error parsing or validating a key. /// -/// The `Display` implementation and `::description()` -/// will return a string that will help you better understand why a key was -/// rejected change which errors are reported in which situations while -/// minimizing the likelihood that any applications will be broken. +/// The `Display` implementation will return a string that will help you better +/// understand why a key was rejected change which errors are reported in which +/// situations while minimizing the likelihood that any applications will be +/// broken. /// /// Here is an incomplete list of reasons a key may be unsupported: /// @@ -147,11 +132,6 @@ impl From for Unspecified { pub struct KeyRejected(&'static str); impl KeyRejected { - /// The value returned from ::description() - pub fn description_(&self) -> &'static str { - self.0 - } - pub(crate) fn inconsistent_components() -> Self { KeyRejected("InconsistentComponents") } @@ -203,19 +183,11 @@ impl KeyRejected { } #[cfg(feature = "std")] -impl std::error::Error for KeyRejected { - fn cause(&self) -> Option<&dyn std::error::Error> { - None - } - - fn description(&self) -> &str { - self.description_() - } -} +impl std::error::Error for KeyRejected {} impl core::fmt::Display for KeyRejected { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.write_str(self.description_()) + f.write_str(self.0) } } diff --git a/tests/ed25519_tests.rs b/tests/ed25519_tests.rs index d800112c9..3fb3c73fe 100644 --- a/tests/ed25519_tests.rs +++ b/tests/ed25519_tests.rs @@ -126,7 +126,7 @@ fn test_ed25519_from_pkcs8_unchecked() { (Ok(_), None) => (), (Err(e), None) => panic!("Failed with error \"{}\", but expected to succeed", e), (Ok(_), Some(e)) => panic!("Succeeded, but expected error \"{}\"", e), - (Err(actual), Some(expected)) => assert_eq!(actual.description_(), expected), + (Err(actual), Some(expected)) => assert_eq!(format!("{}", actual), expected), }; Ok(()) @@ -148,7 +148,7 @@ fn test_ed25519_from_pkcs8() { (Ok(_), None) => (), (Err(e), None) => panic!("Failed with error \"{}\", but expected to succeed", e), (Ok(_), Some(e)) => panic!("Succeeded, but expected error \"{}\"", e), - (Err(actual), Some(expected)) => assert_eq!(actual.description_(), expected), + (Err(actual), Some(expected)) => assert_eq!(format!("{}", actual), expected), }; Ok(())