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
+4 -2
View File
@@ -708,8 +708,10 @@ mod tests {
)]);
// Set computed_tick = 1 (non-zero). Tick 5 is within the 30-tick refresh window.
let mut candidates = DisclosureCandidates::default();
candidates.computed_tick = 1;
let candidates = DisclosureCandidates {
computed_tick: 1,
..Default::default()
};
let npc = app
.world_mut()
+2 -2
View File
@@ -656,7 +656,7 @@ mod tests {
// from derive_mood(). They must be set externally by other systems
// (e.g., observation pipeline for Suspicious, activity scheduler for Focused).
// This test documents the invariant: derive_mood never emits these states.
use std::collections::HashSet;
use std::collections::BTreeSet;
let phases = [
DayPhase::Morning,
@@ -668,7 +668,7 @@ mod tests {
let thresholds: &[i16] = &[0, 1, 50, 100];
let warm_flags = [false, true];
let mut observed = HashSet::new();
let mut observed = BTreeSet::new();
for &phase in &phases {
for &stress in stresses {
for &threshold in thresholds {
+6 -4
View File
@@ -358,10 +358,12 @@ mod tests {
let target_sid = registry.register(target);
spatial.update(target, pos(16, 14));
// Wall between NPC and target
let mut walkability = world.resource_mut::<WalkabilityMap>();
walkability.set_walkable(&pos(16, 15), false);
drop(walkability);
// Wall between NPC and target — scope the mutable resource borrow so it
// is released before the world.insert_resource calls below.
{
let mut walkability = world.resource_mut::<WalkabilityMap>();
walkability.set_walkable(&pos(16, 15), false);
}
world.insert_resource(registry);
world.insert_resource(spatial);
+1 -1
View File
@@ -82,7 +82,7 @@ mod tests {
let values = vec![
SettingValue::String("hello".into()),
SettingValue::Int(-1),
SettingValue::Float(3.14),
SettingValue::Float(2.5),
SettingValue::Bool(false),
];
for val in &values {
+1 -3
View File
@@ -2601,9 +2601,7 @@ mod tests {
});
world.insert_resource(registry);
world
.spawn((PlayerCharacter, TilePosition::new(5, 5, 0)))
.id();
world.spawn((PlayerCharacter, TilePosition::new(5, 5, 0)));
world
}
+3 -7
View File
@@ -441,13 +441,9 @@ mod tests {
fn eavesdrop_threshold_careful_less_than_normal() {
// T4: The careful threshold MUST be strictly less than the normal
// threshold — careful stance rewards patience with faster eavesdrop
// activation (D-053, D-018).
assert!(
EAVESDROP_THRESHOLD_CAREFUL < EAVESDROP_THRESHOLD,
"EAVESDROP_THRESHOLD_CAREFUL ({}) must be < EAVESDROP_THRESHOLD ({})",
EAVESDROP_THRESHOLD_CAREFUL,
EAVESDROP_THRESHOLD,
);
// activation (D-053, D-018). Compile-time invariant: pins the ordering
// so a future const edit can't silently invert it.
const _: () = assert!(EAVESDROP_THRESHOLD_CAREFUL < EAVESDROP_THRESHOLD);
}
// -----------------------------------------------------------------------
+14 -12
View File
@@ -819,12 +819,13 @@ mod tests {
queue.push_anomaly(42, 0);
// Pre-fill the monologue buffer (as if trigger_monologue already wrote)
let mut buffer = MonologueBuffer::default();
buffer.event = Some(MonologueEvent {
id: "existing_line".to_string(),
text: "I should keep this.".to_string(),
duration_seconds: 5.0,
});
let buffer = MonologueBuffer {
event: Some(MonologueEvent {
id: "existing_line".to_string(),
text: "I should keep this.".to_string(),
duration_seconds: 5.0,
}),
};
world.spawn((
PlayerCharacter,
@@ -1074,12 +1075,13 @@ mod tests {
});
// Pre-fill MonologueBuffer (e.g., from trigger_monologue)
let mut buffer = MonologueBuffer::default();
buffer.event = Some(MonologueEvent {
id: "existing_line".to_string(),
text: "Already have something to say.".to_string(),
duration_seconds: 5.0,
});
let buffer = MonologueBuffer {
event: Some(MonologueEvent {
id: "existing_line".to_string(),
text: "Already have something to say.".to_string(),
duration_seconds: 5.0,
}),
};
world.spawn((
PlayerCharacter,
+5 -5
View File
@@ -756,11 +756,11 @@ mod tests {
/// The warn! in process_player_input fires; here we just confirm last-write-wins.
#[test]
fn pending_command_overwrite_last_write_wins() {
let mut pending = SaveLoadPending::default();
pending.pending = Some(SaveLoadCommand::Save {
path: PathBuf::from("/tmp/first.msgpack"),
});
let mut pending = SaveLoadPending {
pending: Some(SaveLoadCommand::Save {
path: PathBuf::from("/tmp/first.msgpack"),
}),
};
// Overwrite with a Load command
pending.pending = Some(SaveLoadCommand::Load {
path: PathBuf::from("/tmp/second.msgpack"),
+2 -2
View File
@@ -17,7 +17,7 @@ use crate::simulation::movement::TilePosition;
/// Typed sound event categories.
/// Client maps each kind to its audio asset registry key (D-038).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum SoundEventKind {
/// Footstep — emitted by moving entities. Intensity varies by stance.
Footstep,
@@ -464,7 +464,7 @@ mod tests {
"all five SoundEventKind variants collected"
);
let collected_kinds: std::collections::HashSet<SoundEventKind> =
let collected_kinds: std::collections::BTreeSet<SoundEventKind> =
queue.events.iter().map(|e| e.kind).collect();
for kind in [
SoundEventKind::Footstep,