From df40f80fcfd5e072a12331f7cbbf65a16691d585 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 16 Dec 2022 10:11:37 -0800 Subject: [PATCH] Make StdError identical to core::error::Error on feature="unstable" --- serde/src/lib.rs | 4 ++-- serde/src/ser/mod.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 9cbd9e758..7f2d79e96 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -88,7 +88,7 @@ // discussion of these features please refer to this issue: // // https://github.com/serde-rs/serde/issues/812 -#![cfg_attr(feature = "unstable", feature(never_type))] +#![cfg_attr(feature = "unstable", feature(error_in_core, never_type))] #![allow(unknown_lints, bare_trait_objects, deprecated)] #![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))] // Ignored clippy and clippy_pedantic lints @@ -303,7 +303,7 @@ use self::__private as private; #[path = "de/seed.rs"] mod seed; -#[cfg(not(feature = "std"))] +#[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 9a21363d6..f44d90633 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -115,10 +115,13 @@ 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(feature = "std"))] +#[cfg(not(any(feature = "std", feature = "unstable")))] #[doc(no_inline)] pub use std_error::Error as StdError;