summaryrefslogtreecommitdiff
path: root/engine-ecs/src/error.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-09-21 23:42:32 +0200
committerHampusM <hampus@hampusmat.com>2026-09-21 23:42:32 +0200
commit7003d9de96824f3e1cb67d56c1c4be883f6e2520 (patch)
tree896578ac2a3250e2bbbc405fbe8e1cf136ab0b90 /engine-ecs/src/error.rs
parentdfa772c8c901500f679249c9a6e0bd25b05ca4d7 (diff)
refactor(engine-ecs): fix clippy lints
Diffstat (limited to 'engine-ecs/src/error.rs')
-rw-r--r--engine-ecs/src/error.rs21
1 files changed, 12 insertions, 9 deletions
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<Ctx>(self, context: Ctx) -> Error
+ #[must_use]
+ pub fn context<Ctx>(self, context: Ctx) -> Self
where
Ctx: Display + Send + Sync + 'static,
{
@@ -112,10 +113,12 @@ where
pub trait Context<T>
{
+ #[allow(clippy::missing_errors_doc)]
fn context<Ctx>(self, context: Ctx) -> Result<T, Error>
where
Ctx: Display + Send + Sync + 'static;
+ #[allow(clippy::missing_errors_doc)]
fn with_context<Ctx>(self, context_func: impl FnOnce() -> Ctx) -> Result<T, Error>
where
Ctx: Display + Send + Sync + 'static;
@@ -157,7 +160,7 @@ impl<T> Context<T> for Result<T, Error>
}
}
-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");