diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index d8b860b2..eac50313 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -101,6 +101,8 @@ use std::error; use collections::{String, Vec}; use core::fmt::{self, Display}; +#[cfg(not(feature = "std"))] +use core::fmt::Debug; use core::marker::PhantomData; /////////////////////////////////////////////////////////////////////////////// @@ -122,7 +124,7 @@ pub use self::ignored_any::IgnoredAny; /////////////////////////////////////////////////////////////////////////////// macro_rules! declare_error_trait { - (Error: Sized $(+ $($supertrait:ident)::*)*) => { + (Error: Sized $(+ $($supertrait:ident)::+)*) => { /// The `Error` trait allows `Deserialize` implementations to create descriptive /// error messages belonging to the `Deserializer` against which they are /// currently running. @@ -136,7 +138,7 @@ macro_rules! declare_error_trait { /// /// Most deserializers should only need to provide the `Error::custom` method /// and inherit the default behavior for the other methods. - pub trait Error: Sized $(+ $($supertrait)::*)* { + pub trait Error: Sized $(+ $($supertrait)::+)* { /// Raised when there is general error when deserializing a type. /// /// The message should not be capitalized and should not end with a period. @@ -254,7 +256,7 @@ macro_rules! declare_error_trait { declare_error_trait!(Error: Sized + error::Error); #[cfg(not(feature = "std"))] -declare_error_trait!(Error: Sized); +declare_error_trait!(Error: Sized + Debug + Display); /// `Unexpected` represents an unexpected invocation of any one of the `Visitor` /// trait methods. diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index 63065e09..5c4f81a9 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -97,6 +97,8 @@ use std::error; #[cfg(all(feature = "collections", not(feature = "std")))] use collections::string::String; +#[cfg(not(feature = "std"))] +use core::fmt::Debug; use core::fmt::Display; #[cfg(any(feature = "std", feature = "collections"))] use core::fmt::Write; @@ -116,11 +118,11 @@ pub use self::impossible::Impossible; /////////////////////////////////////////////////////////////////////////////// macro_rules! declare_error_trait { - (Error: Sized $(+ $($supertrait:ident)::*)*) => { + (Error: Sized $(+ $($supertrait:ident)::+)*) => { /// Trait used by `Serialize` implementations to generically construct /// errors belonging to the `Serializer` against which they are /// currently running. - pub trait Error: Sized $(+ $($supertrait)::*)* { + pub trait Error: Sized $(+ $($supertrait)::+)* { /// Raised when a `Serialize` implementation encounters a general /// error while serializing a type. /// @@ -154,7 +156,7 @@ macro_rules! declare_error_trait { declare_error_trait!(Error: Sized + error::Error); #[cfg(not(feature = "std"))] -declare_error_trait!(Error: Sized); +declare_error_trait!(Error: Sized + Debug + Display); ///////////////////////////////////////////////////////////////////////////////