diff --git a/src/eyreish/error.rs b/src/eyreish/error.rs index cbb4aee..706470e 100644 --- a/src/eyreish/error.rs +++ b/src/eyreish/error.rs @@ -280,7 +280,7 @@ impl Report { /// The root cause is the last error in the iterator produced by /// [`chain()`](Report::chain). pub fn root_cause(&self) -> &(dyn StdError + 'static) { - self.chain().last().unwrap() + self.chain().next_back().unwrap() } /// Returns true if `E` is the type held by this error object. diff --git a/src/handler.rs b/src/handler.rs index c6ac348..c993c43 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -424,7 +424,7 @@ impl HighlighterOption { highlighter: Option, supports_color: bool, ) -> HighlighterOption { - if color == Some(false) || (color == None && !supports_color) { + if color == Some(false) || (color.is_none() && !supports_color) { return HighlighterOption::Disable; } highlighter @@ -433,6 +433,9 @@ impl HighlighterOption { } } +// NOTE: This is manually implemented so that it's clearer what's going on with +// the conditional compilation — clippy isn't picking up the `cfg` stuff here +#[allow(clippy::derivable_impls)] impl Default for HighlighterOption { fn default() -> Self { cfg_if! { diff --git a/src/highlighters/syntect.rs b/src/highlighters/syntect.rs index 538124c..55aa8b6 100644 --- a/src/highlighters/syntect.rs +++ b/src/highlighters/syntect.rs @@ -96,12 +96,12 @@ impl SyntectHighlighter { } } // finally, attempt to guess syntax based on first line - return self.syntax_set.find_syntax_by_first_line( + self.syntax_set.find_syntax_by_first_line( std::str::from_utf8(contents.data()) .ok()? .split('\n') .next()?, - ); + ) } } @@ -115,7 +115,7 @@ pub(crate) struct SyntectHighlighterState<'h> { use_bg_color: bool, } -impl<'h> HighlighterState for SyntectHighlighterState<'h> { +impl HighlighterState for SyntectHighlighterState<'_> { fn highlight_line<'s>(&mut self, line: &'s str) -> Vec> { if let Ok(ops) = self.parse_state.parse_line(line, self.syntax_set) { let use_bg_color = self.use_bg_color;