Skip to content

Commit

Permalink
Merge pull request #820 from dtolnay-contrib/debugerror
Browse files Browse the repository at this point in the history
Remove Debug nesting in errors that only contain an `inner` error
  • Loading branch information
epage authored Dec 16, 2024
2 parents 675edca + 1bbf92a commit f285793
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion crates/toml/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
}

/// Errors that can occur when deserializing a type.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(PartialEq, Eq, Clone)]
pub struct Error {
inner: crate::edit::de::Error,
}
Expand Down Expand Up @@ -87,6 +87,12 @@ impl std::fmt::Display for Error {
}
}

impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.inner.fmt(f)
}
}

impl std::error::Error for Error {}

/// Deserialization TOML document
Expand Down
8 changes: 7 additions & 1 deletion crates/toml/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
}

/// Errors that can occur when serializing a type.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Error {
pub(crate) inner: crate::edit::ser::Error,
}
Expand Down Expand Up @@ -125,6 +125,12 @@ impl std::fmt::Display for Error {
}
}

impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.inner.fmt(f)
}
}

impl std::error::Error for Error {}

/// Serialization for TOML documents.
Expand Down
8 changes: 7 additions & 1 deletion crates/toml_edit/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use table_enum::TableEnumDeserializer;
pub use value::ValueDeserializer;

/// Errors that can occur when deserializing a type.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Error {
inner: crate::TomlError,
}
Expand Down Expand Up @@ -71,6 +71,12 @@ impl std::fmt::Display for Error {
}
}

impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.inner.fmt(f)
}
}

impl From<crate::TomlError> for Error {
fn from(e: crate::TomlError) -> Error {
Self { inner: e }
Expand Down

0 comments on commit f285793

Please sign in to comment.