style(server): clear clippy-1.93 cfg(test)/test-target debt (#967)

Manual clippy-1.93 fixes that the prior machine-applicable sweep couldn't auto-
apply, all in cfg(test) modules and tests/ targets (invisible to the lib-only
pre-push clippy, hence accumulated unflagged):

- disallowed_types HashSet/HashMap → BTreeSet/BTreeMap (determinism rule):
  shadowcast_bench.rs (×8, (i32,i32) keys), mood.rs, sound.rs. SoundEventKind
  gains a PartialOrd/Ord derive (fieldless Copy enum) so it is BTree-usable.
- field_reassign_with_default → struct-init: disclosure.rs, monologue.rs (×2),
  save_io.rs (keeps `mut` for the deliberate last-write-wins overwrite).
- assertions_on_constants on the EAVESDROP_THRESHOLD invariant → compile-time
  `const _: () = assert!(...)`: listening.rs, cross_room_transitions.rs. This is
  stronger than the runtime assert and needs no #[allow].
- approx_constant: settings/types.rs round-trip literal 3.14 → 2.5 (the value is
  arbitrary test data, never meant to be PI — change avoids both the lint and a
  suppression).
- drop_non_drop: vision.rs early Mut<WalkabilityMap> release → scoped block.
- unnecessary_get_then_check → contains_key: information_boundaries.rs (×3).
- cloned_ref_to_slice_refs → std::slice::from_ref: triangle_validation.rs.
- unused_must_use: input.rs dropped the unused .id() on a spawn.

cargo clippy --all-targets -- -D warnings is clean; cargo test green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-23 11:03:15 +02:00
co-authored by Claude Opus 4.7
parent 9a10c6ffd6
commit 8eb6c47f74
13 changed files with 51 additions and 53 deletions
+2 -4
View File
@@ -641,8 +641,6 @@ fn t8_sprint_blocks_eavesdrop_then_careful_enables_accumulation() {
}
// Verify D-071 invariant: Careful threshold is strictly less than normal.
assert!(
EAVESDROP_THRESHOLD_CAREFUL < EAVESDROP_THRESHOLD,
"T8: Careful threshold must be < normal threshold (D-071 invariant)"
);
// Compile-time invariant — pins the ordering against a future const edit.
const _: () = assert!(EAVESDROP_THRESHOLD_CAREFUL < EAVESDROP_THRESHOLD);
}
+3 -3
View File
@@ -59,7 +59,7 @@ fn player_kg_has_no_passive_npc_leakage() {
// Negative assertion: a freshly created KG contains no entity references.
assert!(
player_kg.entities.get(&npc_id).is_none(),
!player_kg.entities.contains_key(&npc_id),
"IB-1: fresh KnowledgeGraph must not contain any entity (passive leakage — D-010 principle 2)"
);
assert!(
@@ -78,7 +78,7 @@ fn player_kg_has_no_passive_npc_leakage() {
// Player's KG must be empty regardless of NPCs existing nearby.
let kg = world.get::<KnowledgeGraph>(player).unwrap();
assert!(
kg.entities.get(&npc_id).is_none(),
!kg.entities.contains_key(&npc_id),
"IB-1: spawning an NPC in the world must not passively populate the player's KG"
);
assert!(
@@ -249,7 +249,7 @@ fn save_state_npc_kg_isolation() {
// NPC_A's KG entry for NPC_B is NPC_A's OBSERVATION DATA (where NPC_A saw NPC_B).
// This is not NPC_B's own KG — it's NPC_A's record of NPC_B's position.
assert!(
kg.entities.get(&npc_b_id).is_some(),
kg.entities.contains_key(&npc_b_id),
"IB-4 sanity: NPC_A's KG should still contain its observation of NPC_B after roundtrip"
);
}
+7 -7
View File
@@ -7,7 +7,7 @@ use rand::Rng;
use rand::SeedableRng;
use rand_chacha::ChaCha8Rng;
use settled_reach_server::perception::shadowcast::{recursive_shadowcast, symmetric_shadowcast};
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::time::Instant;
/// Configuration for a benchmark run
@@ -20,9 +20,9 @@ struct BenchConfig {
}
/// Generate a random wall map with specified density
fn generate_wall_map(size: i32, density: f64, seed: u64) -> HashSet<(i32, i32)> {
fn generate_wall_map(size: i32, density: f64, seed: u64) -> BTreeSet<(i32, i32)> {
let mut rng = ChaCha8Rng::seed_from_u64(seed);
let mut walls = HashSet::new();
let mut walls = BTreeSet::new();
for x in 0..size {
for y in 0..size {
@@ -203,7 +203,7 @@ fn symmetric_algorithm_is_symmetric() {
println!("\n=== Testing Symmetric Property (simplified) ===\n");
// Simple open field test - perfect symmetry should hold here
let no_walls: HashSet<(i32, i32)> = HashSet::new();
let no_walls: BTreeSet<(i32, i32)> = BTreeSet::new();
let is_opaque = |x: i32, y: i32| no_walls.contains(&(x, y));
let test_positions = vec![(0, 0), (3, 3), (5, 2), (1, 7)];
@@ -246,14 +246,14 @@ fn both_algorithms_agree_on_basic_cases() {
println!("\n=== Comparing Algorithm Results ===\n");
let test_cases = vec![
("Open field", HashSet::new()),
("Open field", BTreeSet::new()),
("Single wall at (2,0)", {
let mut w = HashSet::new();
let mut w = BTreeSet::new();
w.insert((2, 0));
w
}),
("L-shaped corridor", {
let mut w = HashSet::new();
let mut w = BTreeSet::new();
for i in 0..5 {
w.insert((i, 2));
w.insert((2, i));
+1 -1
View File
@@ -390,7 +390,7 @@ fn triangle_validation_cross_template_deterministic() {
&mut world1,
hub_id,
bar_id,
&[overridden.clone()],
std::slice::from_ref(&overridden),
&mut SimRng::new(42),
);