fix: warnings from new clippy lints

This commit is contained in:
Freja Roberts 2024-03-29 10:51:15 +01:00
parent 2b32acdd03
commit 90645efddc
3 changed files with 3 additions and 6 deletions

View File

@ -624,7 +624,7 @@ fn capture_handler(error: &(dyn StdError + 'static)) -> Box<dyn EyreHandler> {
} }
impl dyn EyreHandler { impl dyn EyreHandler {
/// /// Check if the handler is of type `T`
pub fn is<T: EyreHandler>(&self) -> bool { pub fn is<T: EyreHandler>(&self) -> bool {
// Get `TypeId` of the type this function is instantiated with. // Get `TypeId` of the type this function is instantiated with.
let t = core::any::TypeId::of::<T>(); let t = core::any::TypeId::of::<T>();
@ -636,7 +636,7 @@ impl dyn EyreHandler {
t == concrete t == concrete
} }
/// /// Downcast the handler to a contcrete type `T`
pub fn downcast_ref<T: EyreHandler>(&self) -> Option<&T> { pub fn downcast_ref<T: EyreHandler>(&self) -> Option<&T> {
if self.is::<T>() { if self.is::<T>() {
unsafe { Some(&*(self as *const dyn EyreHandler as *const T)) } unsafe { Some(&*(self as *const dyn EyreHandler as *const T)) }
@ -645,7 +645,7 @@ impl dyn EyreHandler {
} }
} }
/// /// Downcast the handler to a contcrete type `T`
pub fn downcast_mut<T: EyreHandler>(&mut self) -> Option<&mut T> { pub fn downcast_mut<T: EyreHandler>(&mut self) -> Option<&mut T> {
if self.is::<T>() { if self.is::<T>() {
unsafe { Some(&mut *(self as *mut dyn EyreHandler as *mut T)) } unsafe { Some(&mut *(self as *mut dyn EyreHandler as *mut T)) }

View File

@ -107,7 +107,6 @@ fn test_context() {
Box::new(LocationHandler::new(expected_location)) Box::new(LocationHandler::new(expected_location))
})); }));
use eyre::WrapErr;
let err = read_path("totally_fake_path") let err = read_path("totally_fake_path")
.context("oopsie") .context("oopsie")
.unwrap_err(); .unwrap_err();
@ -126,7 +125,6 @@ fn test_with_context() {
Box::new(LocationHandler::new(expected_location)) Box::new(LocationHandler::new(expected_location))
})); }));
use eyre::WrapErr;
let err = read_path("totally_fake_path") let err = read_path("totally_fake_path")
.with_context(|| "oopsie") .with_context(|| "oopsie")
.unwrap_err(); .unwrap_err();

View File

@ -4,7 +4,6 @@ mod drop;
use self::common::maybe_install_handler; use self::common::maybe_install_handler;
use self::drop::{DetectDrop, Flag}; use self::drop::{DetectDrop, Flag};
use eyre::Report; use eyre::Report;
use std::marker::Unpin;
use std::mem; use std::mem;
#[test] #[test]