Skip to content

Commit 66c1614

Browse files
patowenRalith
authored andcommitted
Fix clippy lints for Rust 1.91.1
1 parent f38bc43 commit 66c1614

File tree

5 files changed

+49
-56
lines changed

5 files changed

+49
-56
lines changed

client/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ impl Config {
5959
data_dirs.push(dir);
6060
}
6161
data_dirs.push(dirs.data_dir().into());
62-
if let Ok(path) = env::current_exe() {
63-
if let Some(dir) = path.parent() {
64-
data_dirs.push(dir.into());
65-
}
62+
if let Ok(path) = env::current_exe()
63+
&& let Some(dir) = path.parent()
64+
{
65+
data_dirs.push(dir.into());
6666
}
6767
#[cfg(feature = "use-repo-assets")]
6868
{

client/src/graphics/draw.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -493,20 +493,15 @@ impl Draw {
493493
.world
494494
.get::<&Position>(entity)
495495
.expect("positionless entity in graph");
496-
if let Some(character_model) = self.loader.get(self.character_model) {
497-
if let Ok(ch) = sim.world.get::<&Character>(entity) {
498-
let transform = na::Matrix4::from(transform * pos.local)
499-
* na::Matrix4::new_scaling(sim.cfg().meters_to_absolute)
500-
* ch.state.orientation.to_homogeneous();
501-
for mesh in &character_model.0 {
502-
self.meshes.draw(
503-
device,
504-
state.common_ds,
505-
cmd,
506-
mesh,
507-
&transform,
508-
);
509-
}
496+
if let Some(character_model) = self.loader.get(self.character_model)
497+
&& let Ok(ch) = sim.world.get::<&Character>(entity)
498+
{
499+
let transform = na::Matrix4::from(transform * pos.local)
500+
* na::Matrix4::new_scaling(sim.cfg().meters_to_absolute)
501+
* ch.state.orientation.to_homogeneous();
502+
for mesh in &character_model.0 {
503+
self.meshes
504+
.draw(device, state.common_ds, cmd, mesh, &transform);
510505
}
511506
}
512507
}

client/src/graphics/voxels/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,19 @@ impl Voxels {
165165
*surface = Some(slot);
166166
let storage = self.extraction_scratch.storage(scratch_slot);
167167
storage.copy_from_slice(&data[..]);
168-
if let Some((lru_slot, lru)) = removed {
169-
if let Populated {
168+
if let Some((lru_slot, lru)) = removed
169+
&& let Populated {
170170
ref mut surface,
171171
ref mut old_surface,
172172
..
173173
} = sim.graph[lru.node].chunks[lru.chunk]
174-
{
175-
// Remove references to released slot IDs
176-
if *surface == Some(lru_slot) {
177-
*surface = None;
178-
}
179-
if *old_surface == Some(lru_slot) {
180-
*old_surface = None;
181-
}
174+
{
175+
// Remove references to released slot IDs
176+
if *surface == Some(lru_slot) {
177+
*surface = None;
178+
}
179+
if *old_surface == Some(lru_slot) {
180+
*old_surface = None;
182181
}
183182
}
184183
let node_is_odd = sim.graph.depth(node) & 1 != 0;

client/src/graphics/window.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ impl Window {
174174
state: ElementState::Pressed,
175175
..
176176
} => {
177-
if self.input.mouse_captured {
178-
if let Some(sim) = self.sim.as_mut() {
179-
sim.set_break_block_pressed_true();
180-
}
177+
if self.input.mouse_captured
178+
&& let Some(sim) = self.sim.as_mut()
179+
{
180+
sim.set_break_block_pressed_true();
181181
}
182182
let _ = self
183183
.window
@@ -191,10 +191,10 @@ impl Window {
191191
state: ElementState::Pressed,
192192
..
193193
} => {
194-
if self.input.mouse_captured {
195-
if let Some(sim) = self.sim.as_mut() {
196-
sim.set_place_block_pressed_true();
197-
}
194+
if self.input.mouse_captured
195+
&& let Some(sim) = self.sim.as_mut()
196+
{
197+
sim.set_place_block_pressed_true();
198198
}
199199
}
200200
WindowEvent::KeyboardInput {
@@ -252,12 +252,11 @@ impl Window {
252252
self.input.mouse_captured = false;
253253
}
254254
_ => {
255-
if let Some(material_idx) = number_key_to_index(key) {
256-
if state == ElementState::Pressed {
257-
if let Some(sim) = self.sim.as_mut() {
258-
sim.select_material(material_idx);
259-
}
260-
}
255+
if let Some(material_idx) = number_key_to_index(key)
256+
&& state == ElementState::Pressed
257+
&& let Some(sim) = self.sim.as_mut()
258+
{
259+
sim.select_material(material_idx);
261260
}
262261
}
263262
},

common/src/graph.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl Graph {
5050
pub fn canonicalize(&self, mut chunk: ChunkId) -> Option<ChunkId> {
5151
for side in chunk.vertex.canonical_sides().into_iter() {
5252
// missing neighbors are always longer
53-
if let Some(neighbor) = self.neighbor(chunk.node, side) {
54-
if self.depth(neighbor) < self.depth(chunk.node) {
55-
chunk.node = neighbor;
56-
}
53+
if let Some(neighbor) = self.neighbor(chunk.node, side)
54+
&& self.depth(neighbor) < self.depth(chunk.node)
55+
{
56+
chunk.node = neighbor;
5757
}
5858
}
5959
Some(chunk)
@@ -69,11 +69,11 @@ impl Graph {
6969
for side in Side::iter() {
7070
// filtering out not-yet-allocated neighbors is fine since
7171
// they have to be longer than us not to be allocated yet
72-
if let Some(neighbor_node) = self.neighbor(node, side) {
73-
if self.depth(neighbor_node) < node_depth {
74-
results[len] = Some((side, neighbor_node));
75-
len += 1;
76-
}
72+
if let Some(neighbor_node) = self.neighbor(node, side)
73+
&& self.depth(neighbor_node) < node_depth
74+
{
75+
results[len] = Some((side, neighbor_node));
76+
len += 1;
7777
}
7878
}
7979

@@ -311,11 +311,11 @@ impl<'a> TreeIter<'a> {
311311
let node_id = self.queue.pop_front()?;
312312
let node = &self.nodes[&node_id];
313313
for side in Side::iter() {
314-
if let Some(neighbor) = node.neighbors[side as usize] {
315-
if !self.visited.contains(&neighbor) {
316-
self.queue.push_back(neighbor);
317-
self.visited.insert(neighbor);
318-
}
314+
if let Some(neighbor) = node.neighbors[side as usize]
315+
&& !self.visited.contains(&neighbor)
316+
{
317+
self.queue.push_back(neighbor);
318+
self.visited.insert(neighbor);
319319
}
320320
}
321321
Some(node)

0 commit comments

Comments
 (0)