Skip to content

Commit ef25f73

Browse files
committed
lints
1 parent 18a6a9e commit ef25f73

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

crates/bevy_render/src/view/visibility/propagate_render_groups.rs

+25-22
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ The base-line performance cost of this algorithm comes from detecting changes, w
131131
- `RemovedComponents<Parent>` is iterated once.
132132
*/
133133

134+
#![allow(clippy::manual_map, clippy::collapsible_match)]
135+
134136
use crate::view::*;
135137

136138
use crate::prelude::Camera;
@@ -217,14 +219,14 @@ impl PropagateRenderGroups {
217219
Self::Camera => {
218220
if !is_camera {
219221
warn!("failed propagating PropagateRenderGroups::Camera, {entity} doesn't have a camera");
220-
RenderGroupsRef::Val(RenderGroups::empty());
222+
return RenderGroupsRef::Val(RenderGroups::empty());
221223
};
222224
RenderGroupsRef::Val(RenderGroups::new_with_camera(entity))
223225
}
224226
Self::CameraWithView => {
225227
if !is_camera {
226228
warn!("failed propagating PropagateRenderGroups::CameraWithView, {entity} doesn't have a camera");
227-
RenderGroupsRef::Val(RenderGroups::empty());
229+
return RenderGroupsRef::Val(RenderGroups::empty());
228230
};
229231
let empty_camera_view = CameraView::empty();
230232
let view = view.unwrap_or(&empty_camera_view);
@@ -233,7 +235,7 @@ impl PropagateRenderGroups {
233235
// Reuse saved allocation.
234236
let mut temp = RenderGroups::default();
235237
std::mem::swap(&mut temp, saved);
236-
temp.set_from_parts(Some(entity), &view.layers());
238+
temp.set_from_parts(Some(entity), view.layers());
237239
RenderGroupsRef::Val(temp)
238240
} else {
239241
// Allocate a new RenderGroups
@@ -255,7 +257,7 @@ impl PropagateRenderGroups {
255257
///
256258
/// ### Merge details
257259
///
258-
/// The merge direction is 'entity_rendergroups.merge(propagated_rendergroups)`
260+
/// The merge direction is `entity_rendergroups.merge(propagated_rendergroups)`
259261
/// (see [`RenderGroups::merge`]).
260262
/// This means the entity's affiliated camera will be prioritized over the propagated affiliated camera.
261263
#[derive(Component, Debug, Clone)]
@@ -380,20 +382,21 @@ impl PropagateRenderGroupsEntityCache {
380382
}
381383
}
382384

383-
/// Removes InheritedRenderGroups from entities with PropagateRenderGroups.
385+
/// Removes `InheritedRenderGroups` from entities with `PropagateRenderGroups`.
384386
fn clean_propagators(
385387
mut commands: Commands,
386388
dirty_propagators: Query<Entity, (With<InheritedRenderGroups>, With<PropagateRenderGroups>)>,
387389
) {
388390
for dirty in dirty_propagators.iter() {
389-
commands.get_entity(dirty).map(|mut e| {
390-
e.remove::<InheritedRenderGroups>();
391-
});
391+
if let Some(mut entity) = commands.get_entity(dirty) {
392+
entity.remove::<InheritedRenderGroups>();
393+
}
392394
}
393395
}
394396

395397
/// Propagates propagation values that have changed.
396398
//todo: Detect if the propagated value has actually changed? Hard to expect this would matter in practice.
399+
#[allow(clippy::too_many_arguments)]
397400
fn propagate_updated_propagators(
398401
mut commands: Commands,
399402
mut updated_entities: ResMut<PropagateRenderGroupsEntityCache>,
@@ -677,7 +680,7 @@ fn apply_new_children_propagation(
677680
}
678681
}
679682

680-
/// Removes InheritedRenderGroups from orphaned branches of the hierarchy.
683+
/// Removes `InheritedRenderGroups` from orphaned branches of the hierarchy.
681684
fn handle_orphaned_nonpropagators(
682685
mut commands: Commands,
683686
mut updated_entities: ResMut<PropagateRenderGroupsEntityCache>,
@@ -714,9 +717,9 @@ fn apply_orphan_cleanup(
714717
maybe_children: Option<&Children>,
715718
) {
716719
// Remove InheritedRenderGroups.
717-
commands.get_entity(entity).map(|mut e| {
718-
e.remove::<InheritedRenderGroups>();
719-
});
720+
if let Some(mut entity) = commands.get_entity(entity) {
721+
entity.remove::<InheritedRenderGroups>();
722+
}
720723

721724
// Mark as updated.
722725
updated_entities.insert(entity);
@@ -741,7 +744,7 @@ fn apply_orphan_cleanup(
741744
}
742745
}
743746

744-
/// Handles entities that lost the PropagateRenderGroups component.
747+
/// Handles entities that lost the `PropagateRenderGroups` component.
745748
fn handle_lost_propagator(
746749
mut commands: Commands,
747750
mut updated_entities: ResMut<PropagateRenderGroupsEntityCache>,
@@ -951,7 +954,7 @@ fn apply_full_propagation_force_update(
951954
}
952955
}
953956

954-
/// Applies InheritedRenderGroups removal to entities for `handle_lost_propagator`,
957+
/// Applies `InheritedRenderGroups` removal to entities for `handle_lost_propagator`,
955958
/// `handle_new_children_nonpropagator`, and `handle_new_parent_nonpropagator`.
956959
fn apply_full_propagation_force_remove(
957960
commands: &mut Commands,
@@ -994,7 +997,7 @@ fn apply_full_propagation_force_remove(
994997
}
995998
}
996999

997-
/// Handles non-propagator entities with InheritedRenderGroups whose children changed.
1000+
/// Handles non-propagator entities with `InheritedRenderGroups` whose children changed.
9981001
fn handle_new_children_nonpropagator(
9991002
mut commands: Commands,
10001003
mut updated_entities: ResMut<PropagateRenderGroupsEntityCache>,
@@ -1089,12 +1092,12 @@ fn handle_new_children_nonpropagator(
10891092
}
10901093
}
10911094

1092-
/// Handles non-propagator entities with InheritedRenderGroups whose parents changed.
1093-
/// - Since handle_new_children_nonpropagator handles all cases where the parent has InheritedRenderGroups, this
1094-
/// system just needs to remove InheritedRenderGroups from non-updated entities and their non-updated descendents
1095-
/// that have InheritedRenderGroups (stopping at propagators and non-updated descendents without
1096-
/// InheritedRenderGroups).
1097-
/// - We skip non-updated entities whose parents are updated, because that implies the current InheritedRenderGroups
1095+
/// Handles non-propagator entities with `InheritedRenderGroups` whose parents changed.
1096+
/// - Since `handle_new_children_nonpropagator` handles all cases where the parent has `InheritedRenderGroups`, this
1097+
/// system just needs to remove `InheritedRenderGroups` from non-updated entities and their non-updated descendents
1098+
/// that have `InheritedRenderGroups` (stopping at propagators and non-updated descendents without
1099+
/// `InheritedRenderGroups`).
1100+
/// - We skip non-updated entities whose parents are updated, because that implies the current `InheritedRenderGroups`
10981101
/// propagator is accurate.
10991102
fn handle_new_parent_nonpropagator(
11001103
mut commands: Commands,
@@ -1151,7 +1154,7 @@ fn handle_new_parent_nonpropagator(
11511154
}
11521155
}
11531156

1154-
/// Handles added/removed/changed RenderGroups for entities with existing InheritedRenderGroups.
1157+
/// Handles added/removed/changed `RenderGroups` for entities with existing `InheritedRenderGroups`.
11551158
fn handle_modified_rendergroups(
11561159
mut updated_entities: ResMut<PropagateRenderGroupsEntityCache>,
11571160
// Entities with InheritedRenderGroups that changed RenderGroups

crates/bevy_render/src/view/visibility/render_groups.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl RenderLayers {
130130

131131
/// Iterates the internal render layers.
132132
pub fn iter(&self) -> impl Iterator<Item = RenderLayer> + '_ {
133-
self.layers.iter().copied().map(Self::iter_layers).flatten()
133+
self.layers.iter().copied().flat_map(Self::iter_layers)
134134
}
135135

136136
/// Returns `true` if the specified render layer is included in this `RenderLayers`.
@@ -327,7 +327,7 @@ impl RenderGroups {
327327
self.camera = self.camera.or(other.camera);
328328
}
329329

330-
/// Copies `other` into `Self.
330+
/// Copies `other` into `Self`.
331331
///
332332
/// This is more efficient than cloning `other` if you want to reuse a `RenderGroups`
333333
/// that is potentially allocated.
@@ -477,7 +477,7 @@ impl<'a> RenderGroupsRef<'a> {
477477
panic!("RenderGroupsRef cannot be dereferenced when empty");
478478
}
479479
Self::Ref(groups) => groups,
480-
Self::Val(groups) => &groups,
480+
Self::Val(groups) => groups,
481481
}
482482
}
483483
}
@@ -494,12 +494,13 @@ pub enum RenderGroupsPtr {
494494
impl RenderGroupsPtr {
495495
/// Gets a reference to the internal [`RenderGroups`].
496496
///
497+
/// # Safety
497498
/// Safety must be established by the user.
498499
pub unsafe fn get(&self) -> &RenderGroups {
499500
match self {
500501
// SAFETY: Safety is established by the caller.
501502
Self::Ptr(groups) => unsafe { groups.as_ref().unwrap() },
502-
Self::Val(groups) => &groups,
503+
Self::Val(groups) => groups,
503504
}
504505
}
505506
}

0 commit comments

Comments
 (0)