Keep only the Clippy rewrites that read as well on stable

CI runs stable Clippy (1.99), which is clean on main. The #[expect(clippy::boxed_local)]
in streaming.rs is unfulfilled there and fails CI under -D warnings, so it goes.
Also back out the rewrites that only satisfied Rust 1.90's Clippy and read
worse: the dragon's range helper and its test, the axolotl test's restated
formula, and two De Morgan expansions (first_person_probe, explosion).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-24 11:31:10 +02:00
parent 040ac1bec4
commit b21423ae01
5 changed files with 13 additions and 42 deletions
@@ -203,7 +203,7 @@ impl HandWorld for Probe<'_> {
let item = self.stack(Hand::Main).effective().0;
// Item.canDestroyBlock: swords' tools cannot destroy in creative.
let sword = item.ends_with("_sword");
let ok = (!sword || !self.creative) && !self.is_air(pos);
let ok = !(sword && self.creative) && !self.is_air(pos);
if ok {
self.blocks.insert(pos, "minecraft:air".into());
}
+4 -24
View File
@@ -27,12 +27,6 @@ const CRYSTAL_IDS: u32 = SPECIAL + 16;
const FIGHT_FILE: &str = "data/minecraft/ender_dragon_fight.dat";
const MAX_HEALTH: f32 = 200.0;
/// Preserve the ordered double comparisons from vanilla: a NaN squared
/// distance fails both comparisons and must not be treated as out of range.
fn target_distance_outside_range(distance_squared: f64) -> bool {
!distance_squared.is_nan() && !(100.0..=22500.0).contains(&distance_squared)
}
#[derive(Default)]
pub(super) struct Fight {
loaded: bool,
@@ -1292,7 +1286,7 @@ impl Game<'_> {
clockwise,
} => {
let dt = far(*target);
if target_distance_outside_range(dt) || collided {
if dt < 100.0 || dt > 22500.0 || collided {
let done = path.as_ref().is_some_and(|p| p.0.done());
let mut chosen = false;
if done {
@@ -1362,7 +1356,7 @@ impl Game<'_> {
*target = Some(Vec3::new(pp.x, pp.y + ho, pp.z));
}
let dt = far(*target);
if target_distance_outside_range(dt) {
if dt < 100.0 || dt > 22500.0 {
if path.as_ref().is_none_or(|p| p.0.done()) {
*path = self.ring_path(clockwise).map(PathBox);
}
@@ -1399,7 +1393,7 @@ impl Game<'_> {
}
Phase::LandingApproach { path, target } => {
let dt = far(*target);
if target_distance_outside_range(dt) || collided {
if dt < 100.0 || dt > 22500.0 || collided {
if path.as_ref().is_none_or(|p| p.0.done()) {
let current = self.closest_node(pos.x, pos.y, pos.z);
// NEAR_EGG_TARGETING: the enemy nearest the egg.
@@ -1583,7 +1577,7 @@ impl Game<'_> {
}
} else {
let dt = far(*target);
if target_distance_outside_range(dt) {
if dt < 100.0 || dt > 22500.0 {
*since += 1;
}
}
@@ -3269,18 +3263,4 @@ mod tests {
let t = nearest_enemy(&players, false, Vec3::new(9.0, 64.0, 0.0), None, |_| true);
assert_eq!(t.map(|p| p.who), Some(FightWho::Host));
}
#[test]
fn target_distance_respects_nan_and_exact_boundaries() {
for (distance, expected) in [
(f64::NAN, false),
(f64::NEG_INFINITY, true),
(99.0, true),
(100.0, false),
(22500.0, false),
(22501.0, true),
(f64::INFINITY, true),
] {
assert_eq!(super::target_distance_outside_range(distance), expected);
}
}
}
+1 -1
View File
@@ -306,7 +306,7 @@ impl Game<'_> {
{
outcome = o;
}
if !spectator && (!creative || !flying) {
if !spectator && !(creative && flying) {
p.velocity = Vec3::new(
p.velocity.x + dir[0] * power,
p.velocity.y + dir[1] * power,
+7 -10
View File
@@ -166,16 +166,13 @@ mod axolotl_parity_tests {
] {
let mut expected = LegacyRandom::new(seed);
let mut actual = LegacyRandom::new(seed);
// The second draw is intentionally consumed even though
// the fixed 4.0 / 14.0 threshold always makes this branch
// true. Removing it changes the native RNG sequence.
let first_gate = !no_ai && expected.next_int_bound(3).unwrap() == 0;
let result = if first_gate {
let _second_draw = expected.next_int_bound(3).unwrap();
water && entity && !already
} else {
false
};
let result = !no_ai
&& expected.next_int_bound(3).unwrap() == 0
&& ((expected.next_int_bound(3).unwrap() as f32) < 2.0 || 4.0f32 / 14.0 < 0.5)
&& 2.0 < 4.0
&& water
&& entity
&& !already;
assert_eq!(
roll_play_dead(&mut actual, no_ai, 4.0, 14.0, 2.0, water, entity, already),
result
-6
View File
@@ -641,12 +641,6 @@ impl Streaming {
});
self.shared.ready.notify_one();
}
// Proto arrays are large; keep ownership of the incoming heap allocation
// instead of moving all nine chunks onto a transient stack frame.
#[expect(
clippy::boxed_local,
reason = "keep nine large Proto values heap resident"
)]
fn receive_decorated(&mut self, x: i32, z: i32, region: Box<[Proto; 9]>) {
self.generation_scan.exhausted = false;
self.decorating -= 1;