Keep Debug and Display as supertraits even in no_std

This commit is contained in:
David Tolnay 2017-04-07 09:00:00 -07:00
parent 21c2119349
commit a581c0d147
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 10 additions and 6 deletions

View File

@ -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.

View File

@ -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);
///////////////////////////////////////////////////////////////////////////////