From 53c8330f210ad7e329caedba7679db6c12872601 Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Sat, 26 Apr 2025 16:43:50 +0100 Subject: [PATCH] refactor(miette): reuse `DiagnosticError` in `protocol.rs` --- src/protocol.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/protocol.rs b/src/protocol.rs index c2df294..96ae9a3 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -12,7 +12,7 @@ use std::{ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use crate::MietteError; +use crate::{DiagnosticError, MietteError}; /// Adds rich metadata to your Error that can be used by /// [`Report`](crate::Report) to print really nice and human-friendly error @@ -174,18 +174,7 @@ impl From for Box { impl From> for Box { fn from(s: Box) -> Self { - #[derive(thiserror::Error)] - #[error(transparent)] - struct BoxedDiagnostic(Box); - impl fmt::Debug for BoxedDiagnostic { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(&self.0, f) - } - } - - impl Diagnostic for BoxedDiagnostic {} - - Box::new(BoxedDiagnostic(s)) + Box::new(DiagnosticError(s)) } }