Skip to content

Commit dded7de

Browse files
authored
fix(color_eyre): build warnings (#182)
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. --- Warnings: ``` Compiling color-eyre v0.6.2 (/Users/joshka/local/eyre/color-eyre) warning: struct `InstallError` is never constructed --> color-eyre/src/config.rs:15:8 | 15 | struct InstallError; | ^^^^^^^^^^^^ | note: the lint level is defined here --> color-eyre/src/lib.rs:352:5 | 352 | unused, | ^^^^^^ = note: `#[warn(dead_code)]` implied by `#[warn(unused)]` warning: struct `InstallThemeError` is never constructed --> color-eyre/src/config.rs:26:8 | 26 | struct InstallThemeError; | ^^^^^^^^^^^^^^^^^ warning: struct `InstallColorSpantraceThemeError` is never constructed --> color-eyre/src/config.rs:37:8 | 37 | struct InstallColorSpantraceThemeError; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait `DisplayExt` is never used --> color-eyre/src/writers.rs:31:18 | 31 | pub(crate) trait DisplayExt: Sized + Display { | ^^^^^^^^^^ warning: struct `FooterWriter` is never constructed --> color-eyre/src/writers.rs:83:19 | 83 | pub(crate) struct FooterWriter<W> { | ^^^^^^^^^^^^ warning: struct `Footer` is never constructed --> color-eyre/src/writers.rs:102:19 | 102 | pub(crate) struct Footer<B, H> | ^^^^^^ warning: struct `Header` is never constructed --> color-eyre/src/writers.rs:133:19 | 133 | pub(crate) struct Header<B, H> | ^^^^^^ warning: `color-eyre` (lib) generated 7 warnings ```
2 parents 9498677 + d717cf9 commit dded7de

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

color-eyre/src/config.rs

-33
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,6 @@ use std::env;
1111
use std::fmt::Write as _;
1212
use std::{fmt, path::PathBuf, sync::Arc};
1313

14-
#[derive(Debug)]
15-
struct InstallError;
16-
17-
impl fmt::Display for InstallError {
18-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19-
f.write_str("could not install the BacktracePrinter as another was already installed")
20-
}
21-
}
22-
23-
impl std::error::Error for InstallError {}
24-
25-
#[derive(Debug)]
26-
struct InstallThemeError;
27-
28-
impl fmt::Display for InstallThemeError {
29-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30-
f.write_str("could not set the provided `Theme` globally as another was already set")
31-
}
32-
}
33-
34-
impl std::error::Error for InstallThemeError {}
35-
36-
#[derive(Debug)]
37-
struct InstallColorSpantraceThemeError;
38-
39-
impl fmt::Display for InstallColorSpantraceThemeError {
40-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41-
f.write_str("could not set the provided `Theme` via `color_spantrace::set_theme` globally as another was already set")
42-
}
43-
}
44-
45-
impl std::error::Error for InstallColorSpantraceThemeError {}
46-
4714
/// A struct that represents a theme that is used by `color_eyre`
4815
#[derive(Debug, Copy, Clone, Default)]
4916
pub struct Theme {

color-eyre/src/writers.rs

+8
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ impl<W> WriterExt for W {
2828
}
2929
}
3030

31+
#[cfg(feature = "issue-url")]
3132
pub(crate) trait DisplayExt: Sized + Display {
3233
fn with_header<H: Display>(self, header: H) -> Header<Self, H>;
3334
fn with_footer<F: Display>(self, footer: F) -> Footer<Self, F>;
3435
}
3536

37+
#[cfg(feature = "issue-url")]
3638
impl<T> DisplayExt for T
3739
where
3840
T: Display,
@@ -80,11 +82,13 @@ where
8082
}
8183
}
8284

85+
#[cfg(feature = "issue-url")]
8386
pub(crate) struct FooterWriter<W> {
8487
inner: W,
8588
had_output: bool,
8689
}
8790

91+
#[cfg(feature = "issue-url")]
8892
impl<W> fmt::Write for FooterWriter<W>
8993
where
9094
W: fmt::Write,
@@ -98,6 +102,7 @@ where
98102
}
99103
}
100104

105+
#[cfg(feature = "issue-url")]
101106
#[allow(explicit_outlives_requirements)]
102107
pub(crate) struct Footer<B, H>
103108
where
@@ -108,6 +113,7 @@ where
108113
footer: H,
109114
}
110115

116+
#[cfg(feature = "issue-url")]
111117
impl<B, H> fmt::Display for Footer<B, H>
112118
where
113119
B: Display,
@@ -129,6 +135,7 @@ where
129135
}
130136
}
131137

138+
#[cfg(feature = "issue-url")]
132139
#[allow(explicit_outlives_requirements)]
133140
pub(crate) struct Header<B, H>
134141
where
@@ -139,6 +146,7 @@ where
139146
h: H,
140147
}
141148

149+
#[cfg(feature = "issue-url")]
142150
impl<B, H> fmt::Display for Header<B, H>
143151
where
144152
B: Display,

0 commit comments

Comments
 (0)