kart: clippy hygiene in engine, pace and mesh tests
- Commit
abf02fb2a5b53e50a08a8f2b1e3eec79a08c22ce- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 21:58 UTC (4 days ago)
- Parents
46de6f2
Workspace clippy flagged: a manual RangeInclusive::contains on the AI pace window (now the range itself), nested index loops over KART_COLORS for the pairwise-distinct check (now iterator pairs over slices), and a constant assertion on the STEP range. STEP is a const, so that assert is an invariant guard that fires on retune, not a foldable check: it stays, under a per-test allow with a comment. Verified: cargo clippy -p kart_engine --all-targets clean, cargo test -p kart_engine (129 passed), fmt clean.
Diff
games/kart/src/main/rust/src/engine/engine_tests.rs
diff --git a/games/kart/src/main/rust/src/engine/engine_tests.rs b/games/kart/src/main/rust/src/engine/engine_tests.rsindex 27acbe4432..cabf2ccbae 100644--- a/games/kart/src/main/rust/src/engine/engine_tests.rs+++ b/games/kart/src/main/rust/src/engine/engine_tests.rs@@ -52,6 +52,10 @@ fn ensure_pending_grows_preserves_and_never_shrinks() { assert_eq!(s.pending.len(), 5); } +// `STEP` is a const, so the range assert is a compile-time-style+// invariant guard (it fires if the const is ever retuned out of+// range), not a runtime check clippy can fold away.+#[allow(clippy::assertions_on_constants)] #[test] fn fixed_step_is_sixty_hertz() { assert!((STEP - 1.0 / 60.0).abs() < 1e-9);
games/kart/src/main/rust/src/items/items_tests.rs
diff --git a/games/kart/src/main/rust/src/items/items_tests.rs b/games/kart/src/main/rust/src/items/items_tests.rsindex fb77a40193..fea07f830c 100644--- a/games/kart/src/main/rust/src/items/items_tests.rs+++ b/games/kart/src/main/rust/src/items/items_tests.rs@@ -62,7 +62,7 @@ fn effective_pace_combines_wobble_boost_and_cap() { // Never exceeds cap, never below base for non-negative deficit. for deficit in [0.0f32, 0.03, 0.2, 1.0, 5.0] { let p = effective_pace(0.95, deficit);- assert!(p >= AI_PACE * 0.95 - 1e-6 && p <= AI_PACE_MAX);+ assert!((AI_PACE * 0.95 - 1e-6..=AI_PACE_MAX).contains(&p)); } }
games/kart/src/main/rust/src/mesh/mesh_tests.rs
diff --git a/games/kart/src/main/rust/src/mesh/mesh_tests.rs b/games/kart/src/main/rust/src/mesh/mesh_tests.rsindex 1c3991f666..02a00d8354 100644--- a/games/kart/src/main/rust/src/mesh/mesh_tests.rs+++ b/games/kart/src/main/rust/src/mesh/mesh_tests.rs@@ -78,9 +78,9 @@ fn kart_mesh_seat_color_wraps_and_ai_darkens() { assert_eq!(seat1[0].color, KART_COLORS[1]); assert_ne!(seat0[0].color, seat1[0].color); // Palette entries are pairwise distinct.- for i in 0..KART_COLORS.len() {- for j in i + 1..KART_COLORS.len() {- assert_ne!(KART_COLORS[i], KART_COLORS[j]);+ for (i, a) in KART_COLORS.iter().enumerate() {+ for b in &KART_COLORS[i + 1..] {+ assert_ne!(a, b); } } }