mirror of https://github.com/zkat/miette.git
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`
This commit is contained in:
parent
d63b2bb638
commit
d0c114311d
|
|
@ -213,5 +213,4 @@ pub(crate) mod private {
|
|||
pub trait Sealed {}
|
||||
|
||||
impl<T, E> Sealed for Result<T, E> where E: ext::Diag {}
|
||||
impl<T> Sealed for Option<T> {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,35 +6,9 @@ use crate::{Diagnostic, LabeledSpan, Report, SourceCode};
|
|||
|
||||
use crate as miette;
|
||||
|
||||
#[repr(transparent)]
|
||||
pub(crate) struct DisplayError<M>(pub(crate) M);
|
||||
|
||||
#[repr(transparent)]
|
||||
pub(crate) struct MessageError<M>(pub(crate) M);
|
||||
|
||||
pub(crate) struct NoneError;
|
||||
|
||||
impl<M> Debug for DisplayError<M>
|
||||
where
|
||||
M: Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<M> Display for DisplayError<M>
|
||||
where
|
||||
M: Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<M> StdError for DisplayError<M> where M: Display + 'static {}
|
||||
impl<M> Diagnostic for DisplayError<M> where M: Display + 'static {}
|
||||
|
||||
impl<M> Debug for MessageError<M>
|
||||
where
|
||||
M: Display + Debug,
|
||||
|
|
@ -56,21 +30,6 @@ where
|
|||
impl<M> StdError for MessageError<M> where M: Display + Debug + 'static {}
|
||||
impl<M> Diagnostic for MessageError<M> 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<dyn Diagnostic + Send + Sync>);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Baz>,
|
||||
}
|
||||
|
||||
#[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<Report>,
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue