Add clippy, fix up warnings #7

Merged
bspeice merged 1 commits from clippy into main 2026-07-12 15:50:25 -04:00
7 changed files with 19 additions and 19 deletions
Showing only changes of commit 9ea4261a84 - Show all commits
+4 -1
View File
@@ -21,7 +21,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- run: cargo check --all-targets - run: cargo check --all-targets
- run: cargo clippy --all-targets
- run: cargo test - run: cargo test
test-gpu: test-gpu:
@@ -30,5 +33,5 @@ jobs:
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - 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 - run: cargo gpu check --auto-install-rust-toolchain -p enkou-shaders
+3 -6
View File
@@ -19,15 +19,12 @@ mod test {
} }
fn has_entry_point(execution_model: ExecutionModel, name: &str) -> bool { 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<Operand> = entry_point let operands: Vec<Operand> = entry_point
.operands .operands
.iter() .iter()
.filter(|op| match op { .filter(|op| matches!(op, Operand::ExecutionModel(_) | Operand::LiteralString(_)))
Operand::ExecutionModel(_) | Operand::LiteralString(_) => true, .cloned()
_ => false,
})
.map(|op| op.clone())
.collect(); .collect();
assert_eq!(operands.len(), 2); assert_eq!(operands.len(), 2);
+3 -4
View File
@@ -78,10 +78,9 @@ pub fn main() -> Result<()> {
image.save(temp.path()).context("Unable to save image")?; image.save(temp.path()).context("Unable to save image")?;
let open_program: &str = cfg_select! { let open_program: &str = cfg_select! {
unix => Some("xdg-open"), unix => "xdg-open",
_ => None, _ => panic!("No available program to open images")
} };
.expect("No available program to open images");
Command::new(open_program) Command::new(open_program)
.arg(temp.path()) .arg(temp.path())
+5 -5
View File
@@ -26,14 +26,14 @@ impl Camera {
/// ///
/// * `dimensions` - Width and height of the output image (in pixels). /// * `dimensions` - Width and height of the output image (in pixels).
/// * `center` - Location of the origin in IFS coordinates. Positive `x` shifts the image /// * `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 /// * `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 /// * `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 /// * `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 /// that the largest dimension will cover the range `[-2, 2]`, but values higher or lower
/// can be used as a secondary zoom. /// can be used as a secondary zoom.
pub fn new(dimensions: UVec2, center: Vec2, rotate: f32, zoom: Vec2, scale: Vec2) -> Camera { pub fn new(dimensions: UVec2, center: Vec2, rotate: f32, zoom: Vec2, scale: Vec2) -> Camera {
let ifs_center_transform = Affine2::from_translation(-center); 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))); let zoom_transform = Affine2::from_scale(vec2(powf(2.0, zoom.x), powf(2.0, zoom.y)));
+2 -1
View File
@@ -1,6 +1,7 @@
//! # Enkou //! # Enkou
#![no_std] #![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 camera;
pub mod chaos_game; pub mod chaos_game;
+1 -1
View File
@@ -24,7 +24,7 @@ pub(crate) fn xoshiro256starstar_from_seed(
// - `u64::from_le_bytes` has issues with `OpBitcast` in SPIR-V validation // - `u64::from_le_bytes` has issues with `OpBitcast` in SPIR-V validation
for i in 0..rng_state_actual.len() { for i in 0..rng_state_actual.len() {
for j in 0..size_of::<u64>() { for j in 0..size_of::<u64>() {
rng_state_actual[i] |= (rng_state[i * size_of::<u64>() + j] as u64) << j * 8; rng_state_actual[i] |= (rng_state[i * size_of::<u64>() + j] as u64) << (j * 8);
} }
} }
+1 -1
View File
@@ -41,7 +41,7 @@ impl Transform {
let variation_start = self.variation_range.x; let variation_start = self.variation_range.x;
let variation_end = self.variation_range.y; let variation_end = self.variation_range.y;
for variation_index in variation_start..variation_end { 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) point_output += variation.transform_point(point, rng, &self.coefficients)
} }