From 9ea4261a84a794243a7e7cf466691b5a40761a1b Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 12 Jul 2026 14:45:46 -0400 Subject: [PATCH] Add clippy, fix up warnings --- .gitea/workflows/ci.yml | 5 ++++- enkou-shaders-tests/src/lib.rs | 9 +++------ enkou-shaders/examples/gasket.rs | 7 +++---- enkou-shaders/src/camera.rs | 10 +++++----- enkou-shaders/src/lib.rs | 3 ++- enkou-shaders/src/rng.rs | 2 +- enkou-shaders/src/transform.rs | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index d17777f..014ec10 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -21,7 +21,10 @@ jobs: steps: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy - run: cargo check --all-targets + - run: cargo clippy --all-targets - run: cargo test test-gpu: @@ -30,5 +33,5 @@ jobs: steps: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 - - run: cargo install --git https://github.com/rust-gpu/rust-gpu cargo-gpu + - run: cargo install --git https://github.com/rust-gpu/rust-gpu cargo-gpu --rev 67f1ff2 - run: cargo gpu check --auto-install-rust-toolchain -p enkou-shaders diff --git a/enkou-shaders-tests/src/lib.rs b/enkou-shaders-tests/src/lib.rs index 5827196..7aa1873 100644 --- a/enkou-shaders-tests/src/lib.rs +++ b/enkou-shaders-tests/src/lib.rs @@ -19,15 +19,12 @@ mod test { } fn has_entry_point(execution_model: ExecutionModel, name: &str) -> bool { - for ref entry_point in shader().entry_points.iter() { + for entry_point in shader().entry_points.iter() { let operands: Vec = entry_point .operands .iter() - .filter(|op| match op { - Operand::ExecutionModel(_) | Operand::LiteralString(_) => true, - _ => false, - }) - .map(|op| op.clone()) + .filter(|op| matches!(op, Operand::ExecutionModel(_) | Operand::LiteralString(_))) + .cloned() .collect(); assert_eq!(operands.len(), 2); diff --git a/enkou-shaders/examples/gasket.rs b/enkou-shaders/examples/gasket.rs index 12ce467..9c3bbe2 100644 --- a/enkou-shaders/examples/gasket.rs +++ b/enkou-shaders/examples/gasket.rs @@ -78,10 +78,9 @@ pub fn main() -> Result<()> { image.save(temp.path()).context("Unable to save image")?; let open_program: &str = cfg_select! { - unix => Some("xdg-open"), - _ => None, - } - .expect("No available program to open images"); + unix => "xdg-open", + _ => panic!("No available program to open images") + }; Command::new(open_program) .arg(temp.path()) diff --git a/enkou-shaders/src/camera.rs b/enkou-shaders/src/camera.rs index 10c4d84..34c9ba8 100644 --- a/enkou-shaders/src/camera.rs +++ b/enkou-shaders/src/camera.rs @@ -26,14 +26,14 @@ impl Camera { /// /// * `dimensions` - Width and height of the output image (in pixels). /// * `center` - Location of the origin in IFS coordinates. Positive `x` shifts the image - /// left, and positive `y` position shifts the image up. + /// left, and positive `y` position shifts the image up. /// * `rotate` - Rotation angle (in radians) of IFS coordinates. Rotation is applied after the - /// `center` translation, so it is about the new origin. + /// `center` translation, so it is about the new origin. /// * `zoom` - Zoom factor applied to IFS coordinates. IFS coordinates are scaled by - /// `pow(2, zoom)`, so a zoom factor of 0 is the identity. + /// `pow(2, zoom)`, so a zoom factor of 0 is the identity. /// * `scale` - Pixels per unit of IFS coordinates. This parameter is usually chosen such - /// that the largest dimension will cover the range `[-2, 2]`, but values higher or lower - /// can be used as a secondary zoom. + /// that the largest dimension will cover the range `[-2, 2]`, but values higher or lower + /// can be used as a secondary zoom. pub fn new(dimensions: UVec2, center: Vec2, rotate: f32, zoom: Vec2, scale: Vec2) -> Camera { let ifs_center_transform = Affine2::from_translation(-center); let zoom_transform = Affine2::from_scale(vec2(powf(2.0, zoom.x), powf(2.0, zoom.y))); diff --git a/enkou-shaders/src/lib.rs b/enkou-shaders/src/lib.rs index 852b104..0cb9009 100644 --- a/enkou-shaders/src/lib.rs +++ b/enkou-shaders/src/lib.rs @@ -1,6 +1,7 @@ //! # Enkou #![no_std] -#![warn(missing_docs)] +#![deny(missing_docs)] +#![allow(clippy::needless_range_loop)] // SPIR-V backend has issues with iteration over items pub mod camera; pub mod chaos_game; diff --git a/enkou-shaders/src/rng.rs b/enkou-shaders/src/rng.rs index 7dbeae8..2169847 100644 --- a/enkou-shaders/src/rng.rs +++ b/enkou-shaders/src/rng.rs @@ -24,7 +24,7 @@ pub(crate) fn xoshiro256starstar_from_seed( // - `u64::from_le_bytes` has issues with `OpBitcast` in SPIR-V validation for i in 0..rng_state_actual.len() { for j in 0..size_of::() { - rng_state_actual[i] |= (rng_state[i * size_of::() + j] as u64) << j * 8; + rng_state_actual[i] |= (rng_state[i * size_of::() + j] as u64) << (j * 8); } } diff --git a/enkou-shaders/src/transform.rs b/enkou-shaders/src/transform.rs index 0c91370..75d63bf 100644 --- a/enkou-shaders/src/transform.rs +++ b/enkou-shaders/src/transform.rs @@ -41,7 +41,7 @@ impl Transform { let variation_start = self.variation_range.x; let variation_end = self.variation_range.y; for variation_index in variation_start..variation_end { - let ref variation = variations[variation_index as usize]; + let variation = &variations[variation_index as usize]; point_output += variation.transform_point(point, rng, &self.coefficients) } -- 2.52.0