From 7003d9de96824f3e1cb67d56c1c4be883f6e2520 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 21 Sep 2026 23:42:32 +0200 Subject: refactor(engine-ecs): fix clippy lints --- engine-ecs/src/error.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'engine-ecs/src/error.rs') diff --git a/engine-ecs/src/error.rs b/engine-ecs/src/error.rs index 5ce5632..67d26d6 100644 --- a/engine-ecs/src/error.rs +++ b/engine-ecs/src/error.rs @@ -38,7 +38,8 @@ impl Error Self { inner: anyhow::Error::msg(message) } } - pub fn context(self, context: Ctx) -> Error + #[must_use] + pub fn context(self, context: Ctx) -> Self where Ctx: Display + Send + Sync + 'static, { @@ -112,10 +113,12 @@ where pub trait Context { + #[allow(clippy::missing_errors_doc)] fn context(self, context: Ctx) -> Result where Ctx: Display + Send + Sync + 'static; + #[allow(clippy::missing_errors_doc)] fn with_context(self, context_func: impl FnOnce() -> Ctx) -> Result where Ctx: Display + Send + Sync + 'static; @@ -157,7 +160,7 @@ impl Context for Result } } -pub type HandlerFn = fn(&World, Error, Metadata); +pub type HandlerFn = fn(&World, Error, &Metadata); /// Error metadata. #[derive(Debug)] @@ -187,7 +190,7 @@ impl Display for SourceKind } } -pub fn err_handler_panic(_world: &World, err: Error, err_metadata: Metadata) +pub fn err_handler_panic(_world: &World, err: Error, err_metadata: &Metadata) { std::panic::panic_any(err.context(format!( "Error occurred in {} '{}'", @@ -195,7 +198,8 @@ pub fn err_handler_panic(_world: &World, err: Error, err_metadata: Metadata) ))); } -pub fn err_handler_log_error(_world: &World, err: Error, err_metadata: Metadata) +#[allow(clippy::needless_pass_by_value)] +pub fn err_handler_log_error(_world: &World, err: Error, err_metadata: &Metadata) { tracing::error!( "Error occurred in {} '{}': {err:#}", @@ -232,18 +236,17 @@ pub(crate) fn set_panic_hook() )); } - println!(""); + println!(); })); } fn get_current_os_thread_id() -> u64 { cfg_select! { - target_os = "linux" => { - (unsafe { libc::gettid() }) as u64 - } + target_os = "linux" => u64::from((unsafe { libc::gettid() }).cast_unsigned()), windows => { - (unsafe { windows_sys::Win32::System::Threading::GetCurrentThreadId() }) as u64 + (unsafe { windows_sys::Win32::System::Threading::GetCurrentThreadId() }) + as u64 } _ => { compile_error!("Unsupported target OS"); -- cgit v1.2.3-18-g5258