From 8a5c662e10d9cb88900e1672e276afe97f3b2b6c Mon Sep 17 00:00:00 2001 From: Serkyo Date: Mon, 13 Jul 2026 00:39:49 +0200 Subject: [PATCH] chore(client): add reasons to expect attributes --- crates/client/src/camera.rs | 5 ++++- crates/client/src/main.rs | 21 ++++++++++++++++----- crates/client/src/meshing.rs | 3 ++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/crates/client/src/camera.rs b/crates/client/src/camera.rs index 6c32a2d..466baab 100644 --- a/crates/client/src/camera.rs +++ b/crates/client/src/camera.rs @@ -59,7 +59,10 @@ impl Camera { /// Advances the camera by a single frame, applying `input` accumulated over `dt` seconds. pub fn update(&mut self, input: &InputState, dt: f32) { // Apply accumulated mouse motion to the orientation. A downward mouse delta (positive y) lowers the pitch, so the vertical term is subtracted. - #[expect(clippy::cast_possible_truncation)] + #[expect( + clippy::cast_possible_truncation, + reason = "mouse deltas are small; f32 precision is sufficient for camera input" + )] { self.yaw += input.mouse_delta.0 as f32 * self.sensitivity; self.pitch -= input.mouse_delta.1 as f32 * self.sensitivity; diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index 1231e40..e1683aa 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -22,8 +22,10 @@ use winit::window::{CursorGrabMode, Window, WindowId}; /// Transient per-frame input state sampled from window and device events. /// /// Keyboard fields hold whether a movement key is currently pressed. `mouse_delta` accumulates raw pointer motion between frames and is consumed (reset to zero) once applied to the camera. -// The bools are independent per-key held states, for which a flat struct is the clearest form. -#[expect(clippy::struct_excessive_bools)] +#[expect( + clippy::struct_excessive_bools, + reason = "per-key held states are independent; a flat bool struct is the clearest representation" +)] #[derive(Default)] struct InputState { /// Whether the "move forward" key (W) is held. @@ -141,10 +143,16 @@ impl ApplicationHandler for App { self.window = Some(window); self.renderer = Some(renderer); - #[expect(clippy::expect_used)] + #[expect( + clippy::expect_used, + reason = "startup asset load; a missing worldgen config is unrecoverable at launch" + )] let config_str = std::fs::read_to_string("assets/data/worldgen/default.json") .expect("Failed to read worldgen config"); - #[expect(clippy::expect_used)] + #[expect( + clippy::expect_used, + reason = "startup config parse; a malformed worldgen config is unrecoverable at launch" + )] let worldgen_config: shared::generator::WorldGenConfig = serde_json::from_str(&config_str).expect("Failed to parse worldgen config"); @@ -160,7 +168,10 @@ impl ApplicationHandler for App { indices.len() ); - #[expect(clippy::expect_used)] + #[expect( + clippy::expect_used, + reason = "the renderer is assigned earlier in this function" + )] self.renderer .as_mut() .expect("Renderer initialized") diff --git a/crates/client/src/meshing.rs b/crates/client/src/meshing.rs index 4e40355..da41f3d 100644 --- a/crates/client/src/meshing.rs +++ b/crates/client/src/meshing.rs @@ -6,7 +6,8 @@ use shared::world::{BlockId, CHUNK_SIZE, Chunk}; #[expect( clippy::cast_precision_loss, clippy::cast_possible_truncation, - clippy::too_many_lines + clippy::too_many_lines, + reason = "voxel coordinates and vertex counts are small and lossless as f32/u32; the per-face unrolling is intentionally long" )] pub fn generate_mesh(chunk: &Chunk) -> (Vec, Vec) { let mut vertices = Vec::new();