From d717cf9cac6f7ca6cad3e28885ab54ad2888a5fc Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Sat, 29 Jun 2024 07:42:39 -0700 Subject: [PATCH] fix(color_eyre): build warnings Remove structs that are unused and have been migrated to use the eyre versions of the same: - color_eyre::config::InstallError -> eyre::InstallError - color_eyre::config::InstallThemeError -> eyre::InstallThemeError - color_eyre::config::InstallColorSpantraceThemeError -> no equivalent Add cfg guards to the DisplayExt, FooterWriter, Footer, and Header to prevent unused warnings when the issue-url feature is not enabled. --- color-eyre/src/config.rs | 33 --------------------------------- color-eyre/src/writers.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/color-eyre/src/config.rs b/color-eyre/src/config.rs index 22b4e60..f8f19b4 100644 --- a/color-eyre/src/config.rs +++ b/color-eyre/src/config.rs @@ -11,39 +11,6 @@ use std::env; use std::fmt::Write as _; use std::{fmt, path::PathBuf, sync::Arc}; -#[derive(Debug)] -struct InstallError; - -impl fmt::Display for InstallError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("could not install the BacktracePrinter as another was already installed") - } -} - -impl std::error::Error for InstallError {} - -#[derive(Debug)] -struct InstallThemeError; - -impl fmt::Display for InstallThemeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("could not set the provided `Theme` globally as another was already set") - } -} - -impl std::error::Error for InstallThemeError {} - -#[derive(Debug)] -struct InstallColorSpantraceThemeError; - -impl fmt::Display for InstallColorSpantraceThemeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("could not set the provided `Theme` via `color_spantrace::set_theme` globally as another was already set") - } -} - -impl std::error::Error for InstallColorSpantraceThemeError {} - /// A struct that represents a theme that is used by `color_eyre` #[derive(Debug, Copy, Clone, Default)] pub struct Theme { diff --git a/color-eyre/src/writers.rs b/color-eyre/src/writers.rs index b5bb344..ce828af 100644 --- a/color-eyre/src/writers.rs +++ b/color-eyre/src/writers.rs @@ -28,11 +28,13 @@ impl WriterExt for W { } } +#[cfg(feature = "issue-url")] pub(crate) trait DisplayExt: Sized + Display { fn with_header(self, header: H) -> Header; fn with_footer(self, footer: F) -> Footer; } +#[cfg(feature = "issue-url")] impl DisplayExt for T where T: Display, @@ -80,11 +82,13 @@ where } } +#[cfg(feature = "issue-url")] pub(crate) struct FooterWriter { inner: W, had_output: bool, } +#[cfg(feature = "issue-url")] impl fmt::Write for FooterWriter where W: fmt::Write, @@ -98,6 +102,7 @@ where } } +#[cfg(feature = "issue-url")] #[allow(explicit_outlives_requirements)] pub(crate) struct Footer where @@ -108,6 +113,7 @@ where footer: H, } +#[cfg(feature = "issue-url")] impl fmt::Display for Footer where B: Display, @@ -129,6 +135,7 @@ where } } +#[cfg(feature = "issue-url")] #[allow(explicit_outlives_requirements)] pub(crate) struct Header where @@ -139,6 +146,7 @@ where h: H, } +#[cfg(feature = "issue-url")] impl fmt::Display for Header where B: Display,