From 2edcc815d382efefaf865ffe739f4a78f47edd58 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Fri, 28 Jul 2023 15:53:20 +0200 Subject: [PATCH] Fix `unstable` build Before: $ cargo +nightly build --no-default-features --features unstable Compiling serde v1.0.177 (/srv/mpn/serde/serde) error[E0432]: unresolved import `std_error` --> serde/src/de/mod.rs:134:9 134 | pub use std_error::Error as StdError; | ^^^^^^^^^ maybe a missing crate `std_error`? After: $ cargo +nightly build --no-default-features --features unstable Compiling serde v1.0.177 (/srv/mpn/serde/serde) Finished dev [unoptimized] target(s) in 1.28s Note that `unstable` and non-`std` tests are still failing. Issue: https://github.com/serde-rs/serde/issues/812 --- serde/src/de/mod.rs | 4 ---- serde/src/lib.rs | 1 - serde/src/ser/mod.rs | 7 ------- serde/src/std_error.rs | 11 +++++++++-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index a04ecf77de..03ca7dfc96 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 10461f46e5..e7afb15a8e 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 e1f38444d0..2b0e7bf916 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 fca023d16c..ed07c7270e 100644 --- a/serde/src/std_error.rs +++ b/serde/src/std_error.rs @@ -1,4 +1,10 @@ -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,7 +46,8 @@ use lib::{Debug, Display}; /// ```edition2021 /// impl serde::ser::StdError for MySerError {} /// ``` -pub trait Error: Debug + Display { +#[cfg(not(any(feature = "std", feature = "unstable")))] +pub trait Error: crate::lib::Debug + crate::lib::Display { /// The underlying cause of this error, if any. fn source(&self) -> Option<&(Error + 'static)> { None