Skip to content

Commit a2b5d7a

Browse files
authored
Fix some nightly warnings (#9672)
# Objective Fix some nightly warnings found by running `cargo +nightly clippy` ## Solution Fix the following warnings: - [x] [elided_lifetimes_in_associated_constant](rust-lang/rust#115010) 2219861 - [x] [unwrap_or_default](https://rust-lang.github.io/rust-clippy/master/index.html#/unwrap_or_default) 32e21c7 - [x] [needless_pass_by_ref_mut](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_pass_by_ref_mut) c85d6d4 There is no breaking change, some internal `bevy_ecs` code no longer uses a few mutable references but I don't think it should cause any regression or be performance sensitive, but there might be some ECS magic I'm unaware of that could break because of those changes
1 parent ce1ac05 commit a2b5d7a

File tree

8 files changed

+20
-23
lines changed

8 files changed

+20
-23
lines changed

crates/bevy_ecs/src/bundle.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl BundleInfo {
349349
&'b self,
350350
entities: &'a mut Entities,
351351
archetypes: &'a mut Archetypes,
352-
components: &mut Components,
352+
components: &Components,
353353
storages: &'a mut Storages,
354354
archetype_id: ArchetypeId,
355355
change_tick: Tick,
@@ -409,7 +409,7 @@ impl BundleInfo {
409409
&'b self,
410410
entities: &'a mut Entities,
411411
archetypes: &'a mut Archetypes,
412-
components: &mut Components,
412+
components: &Components,
413413
storages: &'a mut Storages,
414414
change_tick: Tick,
415415
) -> BundleSpawner<'a, 'b> {
@@ -495,7 +495,7 @@ impl BundleInfo {
495495
&self,
496496
archetypes: &mut Archetypes,
497497
storages: &mut Storages,
498-
components: &mut Components,
498+
components: &Components,
499499
archetype_id: ArchetypeId,
500500
) -> ArchetypeId {
501501
if let Some(add_bundle_id) = archetypes[archetype_id].edges().get_add_bundle(self.id) {
@@ -853,7 +853,7 @@ impl Bundles {
853853
/// provided [`Components`].
854854
pub(crate) fn init_dynamic_info(
855855
&mut self,
856-
components: &mut Components,
856+
components: &Components,
857857
component_ids: &[ComponentId],
858858
) -> (&BundleInfo, &Vec<StorageType>) {
859859
let bundle_infos = &mut self.bundle_infos;
@@ -883,7 +883,7 @@ impl Bundles {
883883
/// Panics if the provided [`ComponentId`] does not exist in the provided [`Components`].
884884
pub(crate) fn init_component_info(
885885
&mut self,
886-
components: &mut Components,
886+
components: &Components,
887887
component_id: ComponentId,
888888
) -> (&BundleInfo, StorageType) {
889889
let bundle_infos = &mut self.bundle_infos;

crates/bevy_ecs/src/world/entity_ref.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl<'w> EntityWorldMut<'w> {
576576
let mut bundle_inserter = bundle_info.get_bundle_inserter(
577577
&mut self.world.entities,
578578
&mut self.world.archetypes,
579-
&mut self.world.components,
579+
&self.world.components,
580580
&mut self.world.storages,
581581
self.location.archetype_id,
582582
change_tick,
@@ -613,7 +613,7 @@ impl<'w> EntityWorldMut<'w> {
613613
let bundle_inserter = bundle_info.get_bundle_inserter(
614614
&mut self.world.entities,
615615
&mut self.world.archetypes,
616-
&mut self.world.components,
616+
&self.world.components,
617617
&mut self.world.storages,
618618
self.location.archetype_id,
619619
change_tick,
@@ -656,7 +656,7 @@ impl<'w> EntityWorldMut<'w> {
656656
let bundle_inserter = bundle_info.get_bundle_inserter(
657657
&mut self.world.entities,
658658
&mut self.world.archetypes,
659-
&mut self.world.components,
659+
&self.world.components,
660660
&mut self.world.storages,
661661
self.location.archetype_id,
662662
change_tick,
@@ -1084,7 +1084,7 @@ unsafe fn insert_dynamic_bundle<
10841084
unsafe fn remove_bundle_from_archetype(
10851085
archetypes: &mut Archetypes,
10861086
storages: &mut Storages,
1087-
components: &mut Components,
1087+
components: &Components,
10881088
archetype_id: ArchetypeId,
10891089
bundle_info: &BundleInfo,
10901090
intersection: bool,

crates/bevy_ecs/src/world/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl World {
740740
let mut spawner = bundle_info.get_bundle_spawner(
741741
&mut self.entities,
742742
&mut self.archetypes,
743-
&mut self.components,
743+
&self.components,
744744
&mut self.storages,
745745
change_tick,
746746
);
@@ -1448,7 +1448,7 @@ impl World {
14481448
let mut spawn_or_insert = SpawnOrInsert::Spawn(bundle_info.get_bundle_spawner(
14491449
&mut self.entities,
14501450
&mut self.archetypes,
1451-
&mut self.components,
1451+
&self.components,
14521452
&mut self.storages,
14531453
change_tick,
14541454
));
@@ -1471,7 +1471,7 @@ impl World {
14711471
let mut inserter = bundle_info.get_bundle_inserter(
14721472
&mut self.entities,
14731473
&mut self.archetypes,
1474-
&mut self.components,
1474+
&self.components,
14751475
&mut self.storages,
14761476
location.archetype_id,
14771477
change_tick,
@@ -1491,7 +1491,7 @@ impl World {
14911491
let mut spawner = bundle_info.get_bundle_spawner(
14921492
&mut self.entities,
14931493
&mut self.archetypes,
1494-
&mut self.components,
1494+
&self.components,
14951495
&mut self.storages,
14961496
change_tick,
14971497
);

crates/bevy_ecs/src/world/spawn_batch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
let mut spawner = bundle_info.get_bundle_spawner(
4242
&mut world.entities,
4343
&mut world.archetypes,
44-
&mut world.components,
44+
&world.components,
4545
&mut world.storages,
4646
change_tick,
4747
);

crates/bevy_reflect/src/path/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl fmt::Display for Token<'_> {
152152
}
153153
}
154154
impl<'a> Token<'a> {
155-
const SYMBOLS: &[u8] = b".#[]";
155+
const SYMBOLS: &'static [u8] = b".#[]";
156156
fn symbol_from_byte(byte: u8) -> Option<Self> {
157157
match byte {
158158
b'.' => Some(Self::Dot),

crates/bevy_scene/src/scene_spawner.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl SceneSpawner {
139139
let spawned = self
140140
.spawned_dynamic_scenes
141141
.entry(scene_handle.clone())
142-
.or_insert_with(Vec::new);
142+
.or_default();
143143
spawned.push(instance_id);
144144
Ok(())
145145
}
@@ -186,10 +186,7 @@ impl SceneSpawner {
186186
scene.write_to_world_with(world, &world.resource::<AppTypeRegistry>().clone())?;
187187

188188
self.spawned_instances.insert(instance_id, instance_info);
189-
let spawned = self
190-
.spawned_scenes
191-
.entry(scene_handle)
192-
.or_insert_with(Vec::new);
189+
let spawned = self.spawned_scenes.entry(scene_handle).or_default();
193190
spawned.push(instance_id);
194191
Ok(instance_id)
195192
})

crates/bevy_winit/src/system.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) fn create_windows<'a>(
4444
mut winit_windows: NonSendMut<WinitWindows>,
4545
mut adapters: NonSendMut<AccessKitAdapters>,
4646
mut handlers: ResMut<WinitActionHandlers>,
47-
mut accessibility_requested: ResMut<AccessibilityRequested>,
47+
accessibility_requested: ResMut<AccessibilityRequested>,
4848
#[cfg(target_arch = "wasm32")] event_channel: ResMut<CanvasParentResizeEventChannel>,
4949
) {
5050
for (entity, mut window) in created_windows {
@@ -64,7 +64,7 @@ pub(crate) fn create_windows<'a>(
6464
&window,
6565
&mut adapters,
6666
&mut handlers,
67-
&mut accessibility_requested,
67+
&accessibility_requested,
6868
);
6969

7070
if let Some(theme) = winit_window.theme() {

crates/bevy_winit/src/winit_windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl WinitWindows {
4646
window: &Window,
4747
adapters: &mut AccessKitAdapters,
4848
handlers: &mut WinitActionHandlers,
49-
accessibility_requested: &mut AccessibilityRequested,
49+
accessibility_requested: &AccessibilityRequested,
5050
) -> &winit::window::Window {
5151
let mut winit_window_builder = winit::window::WindowBuilder::new();
5252

0 commit comments

Comments
 (0)