From b5c9bffe5006b282f7fa42f05647a027171fa9a8 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Tue, 5 Nov 2024 16:48:31 +0100 Subject: [PATCH] Core::errors::Error is stable now (#2664) --- libafl_bolts/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libafl_bolts/src/lib.rs b/libafl_bolts/src/lib.rs index c48bdce1ad..a1646a90b0 100644 --- a/libafl_bolts/src/lib.rs +++ b/libafl_bolts/src/lib.rs @@ -451,6 +451,17 @@ impl Error { } } +impl core::error::Error for Error { + #[cfg(feature = "std")] + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + if let Self::OsError(err, _, _) = self { + Some(err) + } else { + None + } + } +} + impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { @@ -638,12 +649,6 @@ impl From for Error { } } -#[cfg(all(not(nightly), feature = "std"))] -impl std::error::Error for Error {} - -#[cfg(nightly)] -impl core::error::Error for Error {} - /// The purpose of this module is to alleviate imports of many components by adding a glob import. #[cfg(feature = "prelude")] pub mod prelude {