diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index a04ecf77d..03ca7dfc9 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -126,10 +126,6 @@ mod utf8; pub use self::ignored_any::IgnoredAny; -#[cfg(feature = "std")] -#[doc(no_inline)] -pub use std::error::Error as StdError; -#[cfg(not(feature = "std"))] #[doc(no_inline)] pub use std_error::Error as StdError; diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 10461f46e..e7afb15a8 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -328,7 +328,6 @@ use self::__private as private; #[path = "de/seed.rs"] mod seed; -#[cfg(not(any(feature = "std", feature = "unstable")))] mod std_error; // Re-export #[derive(Serialize, Deserialize)]. diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index e1f38444d..2b0e7bf91 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -115,13 +115,6 @@ mod impossible; pub use self::impossible::Impossible; -#[cfg(all(feature = "unstable", not(feature = "std")))] -#[doc(inline)] -pub use core::error::Error as StdError; -#[cfg(feature = "std")] -#[doc(no_inline)] -pub use std::error::Error as StdError; -#[cfg(not(any(feature = "std", feature = "unstable")))] #[doc(no_inline)] pub use std_error::Error as StdError; diff --git a/serde/src/std_error.rs b/serde/src/std_error.rs index fca023d16..4b08d74f9 100644 --- a/serde/src/std_error.rs +++ b/serde/src/std_error.rs @@ -1,5 +1,14 @@ +#[cfg(not(any(feature = "std", feature = "unstable")))] use lib::{Debug, Display}; +#[cfg(all(feature = "unstable", not(feature = "std")))] +#[doc(no_inline)] +pub use core::error::Error; + +#[cfg(feature = "std")] +#[doc(no_inline)] +pub use std::error::Error; + /// Either a re-export of std::error::Error or a new identical trait, depending /// on whether Serde's "std" feature is enabled. /// @@ -40,6 +49,7 @@ use lib::{Debug, Display}; /// ```edition2021 /// impl serde::ser::StdError for MySerError {} /// ``` +#[cfg(not(any(feature = "std", feature = "unstable")))] pub trait Error: Debug + Display { /// The underlying cause of this error, if any. fn source(&self) -> Option<&(Error + 'static)> {