From 60427da1110c2cba743eb13023ad3e5427bdf34f Mon Sep 17 00:00:00 2001 From: Nahor Date: Tue, 19 Mar 2024 10:49:17 -0700 Subject: [PATCH] fix(miri): remove or mark as dead_code unused internal structs - Mark as dead_code the structs uses in testing - Remove unused code inherited from Eyre for converting `Option` into `Result` --- src/eyreish/context.rs | 1 - src/eyreish/wrapper.rs | 41 ----------------------------------------- tests/derive.rs | 6 ++++++ 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/src/eyreish/context.rs b/src/eyreish/context.rs index 3d9238b2..e3d41a7b 100644 --- a/src/eyreish/context.rs +++ b/src/eyreish/context.rs @@ -213,5 +213,4 @@ pub(crate) mod private { pub trait Sealed {} impl Sealed for Result where E: ext::Diag {} - impl Sealed for Option {} } diff --git a/src/eyreish/wrapper.rs b/src/eyreish/wrapper.rs index 01f64f09..a95b7d95 100644 --- a/src/eyreish/wrapper.rs +++ b/src/eyreish/wrapper.rs @@ -6,35 +6,9 @@ use crate::{Diagnostic, LabeledSpan, Report, SourceCode}; use crate as miette; -#[repr(transparent)] -pub(crate) struct DisplayError(pub(crate) M); - #[repr(transparent)] pub(crate) struct MessageError(pub(crate) M); -pub(crate) struct NoneError; - -impl Debug for DisplayError -where - M: Display, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - Display::fmt(&self.0, f) - } -} - -impl Display for DisplayError -where - M: Display, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - Display::fmt(&self.0, f) - } -} - -impl StdError for DisplayError where M: Display + 'static {} -impl Diagnostic for DisplayError where M: Display + 'static {} - impl Debug for MessageError where M: Display + Debug, @@ -56,21 +30,6 @@ where impl StdError for MessageError where M: Display + Debug + 'static {} impl Diagnostic for MessageError where M: Display + Debug + 'static {} -impl Debug for NoneError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - Debug::fmt("Option was None", f) - } -} - -impl Display for NoneError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - Display::fmt("Option was None", f) - } -} - -impl StdError for NoneError {} -impl Diagnostic for NoneError {} - #[repr(transparent)] pub(crate) struct BoxedError(pub(crate) Box); diff --git a/tests/derive.rs b/tests/derive.rs index ac29eee6..aa631dc5 100644 --- a/tests/derive.rs +++ b/tests/derive.rs @@ -6,12 +6,14 @@ fn related() { #[derive(Error, Debug, Diagnostic)] #[error("welp")] #[diagnostic(code(foo::bar::baz))] + #[allow(dead_code)] struct Foo { #[related] related: Vec, } #[derive(Error, Debug, Diagnostic)] + #[allow(dead_code)] enum Bar { #[error("variant1")] #[diagnostic(code(foo::bar::baz))] @@ -29,6 +31,7 @@ fn related() { #[derive(Error, Debug, Diagnostic)] #[error("welp2")] + #[allow(dead_code)] struct Baz; } @@ -37,6 +40,7 @@ fn related_report() { #[derive(Error, Debug, Diagnostic)] #[error("welp")] #[diagnostic(code(foo::bar::baz))] + #[allow(dead_code)] struct Foo { #[related] related: Vec, @@ -288,6 +292,7 @@ fn test_snippet_named_struct() { #[derive(Debug, Diagnostic, Error)] #[error("welp")] #[diagnostic(code(foo::bar::baz))] + #[allow(dead_code)] struct Foo<'a> { #[source_code] src: &'a str, @@ -310,6 +315,7 @@ fn test_snippet_unnamed_struct() { #[derive(Debug, Diagnostic, Error)] #[error("welp")] #[diagnostic(code(foo::bar::baz))] + #[allow(dead_code)] struct Foo<'a>( #[source_code] &'a str, #[label("{0}")] SourceSpan,