voxels: clippy hygiene in pipeline builders and world tests
- Commit
1f17e4030928ff4d67a67ec6f8cbc10d62c6adf3- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 22:01 UTC (4 days ago)
- Parents
e4c41b0
Workspace clippy flagged: double references into ash pipeline builders in pipeline_helpers (the builders deref them; same create-info values), an index loop over chunk sections in save.rs (now iter_mut().take(..), same break/continue cursor logic), two redundant encode_chunk closures, an assert_eq! against true, an == false solid check, a redundant len >= 1 beside !is_empty, and if-inside-match biome arms (now match guards with the same fallthrough). The GRASS_SIDE_TILE >= 256 constant assertion is an invariant guard over two consts and stays under a per-test allow with a comment. Verified: cargo clippy -p voxels_engine --all-targets clean, cargo test -p voxels_engine (252 passed), fmt clean.
Diff
games/voxels/src/main/rust/src/entity_coverage_tests.rs
diff --git a/games/voxels/src/main/rust/src/entity_coverage_tests.rs b/games/voxels/src/main/rust/src/entity_coverage_tests.rsindex 37b9fefdf1..187a1a802c 100644--- a/games/voxels/src/main/rust/src/entity_coverage_tests.rs+++ b/games/voxels/src/main/rust/src/entity_coverage_tests.rs@@ -8,7 +8,7 @@ fn kind_tables_are_coherent() { assert_eq!(MobKind::ALL.len(), 13); for kind in MobKind::ALL { assert_eq!(MobKind::from_cell(kind.cell()), kind);- assert_eq!(kind.cell() < 13, true);+ assert!(kind.cell() < 13); // Loot ids are real items/blocks or empty for villagers. for &id in kind.loot() { assert!(id != 0);
games/voxels/src/main/rust/src/net_extra_tests.rs
diff --git a/games/voxels/src/main/rust/src/net_extra_tests.rs b/games/voxels/src/main/rust/src/net_extra_tests.rsindex c9645d1bb0..883736098c 100644--- a/games/voxels/src/main/rust/src/net_extra_tests.rs+++ b/games/voxels/src/main/rust/src/net_extra_tests.rs@@ -50,7 +50,7 @@ fn host_applies_chunk_container_and_place_intents() { let data = s .chunks .get(ChunkPos(0, 0))- .map(|c| crate::world::save::encode_chunk(c))+ .map(crate::world::save::encode_chunk) .unwrap_or_default(); push(NetMsg::ChunkData { dim: s.dim, cx: 0, cz: 0, data }); push(NetMsg::ChunkData { dim: s.dim, cx: 1, cz: 1, data: vec![0xFF, 0x00, 0x13] });@@ -109,7 +109,7 @@ fn host_applies_chunk_container_and_place_intents() { let data = c .chunks .get(ChunkPos(0, 0))- .map(|ch| crate::world::save::encode_chunk(ch))+ .map(crate::world::save::encode_chunk) .unwrap_or_default(); push(NetMsg::ChunkData { dim: c.dim, cx: 0, cz: 0, data }); push(NetMsg::ChunkData { dim: 9, cx: 0, cz: 0, data: vec![] }); // wrong dim: ignored
games/voxels/src/main/rust/src/vulkan/pipeline/pipeline_helpers.rs
diff --git a/games/voxels/src/main/rust/src/vulkan/pipeline/pipeline_helpers.rs b/games/voxels/src/main/rust/src/vulkan/pipeline/pipeline_helpers.rsindex f440057c61..56894bffa7 100644--- a/games/voxels/src/main/rust/src/vulkan/pipeline/pipeline_helpers.rs+++ b/games/voxels/src/main/rust/src/vulkan/pipeline/pipeline_helpers.rs@@ -179,22 +179,22 @@ pub(super) unsafe fn create_post_pipelines( vk::PipelineShaderStageCreateInfo::default() .stage(vk::ShaderStageFlags::VERTEX) .module(post_vert_mod)- .name(&entry),+ .name(entry), vk::PipelineShaderStageCreateInfo::default() .stage(vk::ShaderStageFlags::FRAGMENT) .module(frag)- .name(&entry),+ .name(entry), ]; let pi = vk::GraphicsPipelineCreateInfo::default() .stages(&stages) .vertex_input_state(&empty_vi)- .input_assembly_state(&ia)- .viewport_state(&vp_state)- .rasterization_state(&raster)- .multisample_state(&ms)+ .input_assembly_state(ia)+ .viewport_state(vp_state)+ .rasterization_state(raster)+ .multisample_state(ms) .depth_stencil_state(&post_ds) .color_blend_state(&post_cb)- .dynamic_state(&dyn_state)+ .dynamic_state(dyn_state) .layout(post_layout) .render_pass(rp) .subpass(0);
games/voxels/src/main/rust/src/world/block_tests.rs
diff --git a/games/voxels/src/main/rust/src/world/block_tests.rs b/games/voxels/src/main/rust/src/world/block_tests.rsindex 4a94eed513..a9995ad821 100644--- a/games/voxels/src/main/rust/src/world/block_tests.rs+++ b/games/voxels/src/main/rust/src/world/block_tests.rs@@ -180,6 +180,9 @@ fn atlas_tiles_fit_the_atlas_and_follow_the_parent() { } #[test]+// `GRASS_SIDE_TILE >= 256` relates two consts: an invariant+// guard that fires if the sentinel is ever renumbered.+#[allow(clippy::assertions_on_constants)] fn tile_uv_maps_corners_and_stays_in_unit_space() { assert_eq!(tile_uv(0), (0.0, 0.0, 0.0625, 0.0625)); assert_eq!(tile_uv(17), (0.0625, 0.0625, 0.125, 0.125));@@ -240,7 +243,7 @@ fn menus_pickaxes_and_solidity_are_pinned() { ); } }- assert!(Block::Stone.is_solid() && Block::Glass.is_solid() == false);+ assert!(Block::Stone.is_solid() && !Block::Glass.is_solid()); assert!(!Block::Water.is_solid() && !Block::WheatCrop.is_solid()); }
games/voxels/src/main/rust/src/world/chunk_coverage_tests.rs
diff --git a/games/voxels/src/main/rust/src/world/chunk_coverage_tests.rs b/games/voxels/src/main/rust/src/world/chunk_coverage_tests.rsindex e0ca2947a2..97ca22e25d 100644--- a/games/voxels/src/main/rust/src/world/chunk_coverage_tests.rs+++ b/games/voxels/src/main/rust/src/world/chunk_coverage_tests.rs@@ -58,7 +58,7 @@ fn chunk_map_world_edges_and_tint() { assert_eq!(map.get_block_world(-3, 100, -3), 9); assert_eq!(map.get(ChunkPos::from_world(-3, -3)).map(|c| c.pos), Some(ChunkPos(-1, -1))); assert!(map.get_mut(ChunkPos(99, 99)).is_none());- assert!(!map.is_empty() && map.len() >= 1);+ assert!(!map.is_empty()); assert_eq!(map.dim(), 0); assert_eq!(ChunkMap::new_dim(4, temp("nether"), 1).dim(), 1); // Grass tint is a colour: finite, in range, deterministic.
games/voxels/src/main/rust/src/world/generator_coverage_tests.rs
diff --git a/games/voxels/src/main/rust/src/world/generator_coverage_tests.rs b/games/voxels/src/main/rust/src/world/generator_coverage_tests.rsindex ac52931ee0..9dc0b6a2f1 100644--- a/games/voxels/src/main/rust/src/world/generator_coverage_tests.rs+++ b/games/voxels/src/main/rust/src/world/generator_coverage_tests.rs@@ -190,15 +190,11 @@ fn desert_chunks_dress_themselves() { for wz in (-600..600).step_by(8) { let h = gen.height_at(wx as f64, wz as f64); match gen.biome_at(wx as f64, wz as f64, h) {- Biome::Desert | Biome::Badlands => {- if desert.is_none() {- desert = Some((wx, wz));- }+ Biome::Desert | Biome::Badlands if desert.is_none() => {+ desert = Some((wx, wz)); }- Biome::SnowyTaiga | Biome::SnowyPlains | Biome::IceSpikes => {- if cold.is_none() {- cold = Some((wx, wz));- }+ Biome::SnowyTaiga | Biome::SnowyPlains | Biome::IceSpikes if cold.is_none() => {+ cold = Some((wx, wz)); } _ => {} }
games/voxels/src/main/rust/src/world/save.rs
diff --git a/games/voxels/src/main/rust/src/world/save.rs b/games/voxels/src/main/rust/src/world/save.rsindex 7dd3a524b6..0e51854bb8 100644--- a/games/voxels/src/main/rust/src/world/save.rs+++ b/games/voxels/src/main/rust/src/world/save.rs@@ -71,7 +71,7 @@ pub fn decode_chunk(bytes: &[u8], chunk: &mut Chunk) -> std::io::Result<()> { // corrupt payload leaves the live chunk untouched instead of half-applied. let mut sections: [Option<super::chunk::BlockSection>; SECTIONS_PER_CHUNK] = std::array::from_fn(|_| None);- for sec_idx in 0..sec_count.min(SECTIONS_PER_CHUNK) {+ for slot in sections.iter_mut().take(sec_count.min(SECTIONS_PER_CHUNK)) { if off >= bytes.len() { break; }@@ -105,7 +105,7 @@ pub fn decode_chunk(bytes: &[u8], chunk: &mut Chunk) -> std::io::Result<()> { } let non_air = blocks.iter().filter(|&&b| b != 0).count(); if non_air > 0 {- sections[sec_idx] = Some(super::chunk::BlockSection { blocks, meta, non_air });+ *slot = Some(super::chunk::BlockSection { blocks, meta, non_air }); } } chunk.sections = sections;