Skip to content

Commit 5ffff03

Browse files
committed
Fix some nightly clippy lints (#2522)
on nightly these two clippy lints fail: - [needless_borrow](https://rust-lang.github.io/rust-clippy/master/#needless_borrow) - [unused_unit](https://rust-lang.github.io/rust-clippy/master/#unused_unit)
1 parent 86cc70b commit 5ffff03

File tree

34 files changed

+104
-101
lines changed

34 files changed

+104
-101
lines changed

crates/bevy_asset/src/asset_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl AssetServer {
478478
.expect("Asset should exist at this point.");
479479
if let Some(asset_lifecycle) = asset_lifecycles.get(&asset_value.type_uuid()) {
480480
let asset_path =
481-
AssetPath::new_ref(&load_context.path, label.as_ref().map(|l| l.as_str()));
481+
AssetPath::new_ref(load_context.path, label.as_ref().map(|l| l.as_str()));
482482
asset_lifecycle.create_asset(asset_path.into(), asset_value, load_context.version);
483483
} else {
484484
panic!(

crates/bevy_asset/src/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> LoadContext<'a> {
101101
}
102102

103103
pub fn path(&self) -> &Path {
104-
&self.path
104+
self.path
105105
}
106106

107107
pub fn has_labeled_asset(&self, label: &str) -> bool {

crates/bevy_audio/src/audio_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ where
4545
{
4646
fn play_source(&self, audio_source: &P) {
4747
if let Some(stream_handle) = &self.stream_handle {
48-
let sink = Sink::try_new(&stream_handle).unwrap();
48+
let sink = Sink::try_new(stream_handle).unwrap();
4949
sink.append(audio_source.decoder());
5050
sink.detach();
5151
}

crates/bevy_core/src/label.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub(crate) fn entity_labels_system(
107107
}
108108
}
109109

110-
for added_label in labels.labels.difference(&current_labels) {
110+
for added_label in labels.labels.difference(current_labels) {
111111
entity_labels
112112
.label_entities
113113
.entry(added_label.clone())

crates/bevy_ecs/src/bundle.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ macro_rules! tuple_impl {
7272
}
7373

7474
#[allow(unused_variables, unused_mut)]
75+
#[allow(clippy::unused_unit)]
7576
unsafe fn from_components(mut func: impl FnMut() -> *mut u8) -> Self {
7677
#[allow(non_snake_case)]
7778
let ($(mut $name,)*) = (

crates/bevy_ecs/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ mod tests {
737737
fn get_added<Com: Component>(world: &mut World) -> Vec<Entity> {
738738
world
739739
.query_filtered::<Entity, Added<Com>>()
740-
.iter(&world)
740+
.iter(world)
741741
.collect::<Vec<Entity>>()
742742
}
743743

@@ -781,7 +781,7 @@ mod tests {
781781
{
782782
world
783783
.query_filtered::<Entity, F>()
784-
.iter(&world)
784+
.iter(world)
785785
.collect::<Vec<Entity>>()
786786
}
787787

@@ -868,7 +868,7 @@ mod tests {
868868
fn get_changed(world: &mut World) -> Vec<Entity> {
869869
world
870870
.query_filtered::<Entity, Changed<A>>()
871-
.iter(&world)
871+
.iter(world)
872872
.collect::<Vec<Entity>>()
873873
}
874874
assert_eq!(get_changed(&mut world), vec![e1]);

crates/bevy_ecs/src/query/access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<T: SparseSetIndex> FilteredAccessSet<T> {
197197
// compatibility
198198
if !filtered_access.access.is_compatible(&self.combined_access) {
199199
for current_filtered_access in self.filtered_accesses.iter() {
200-
if !current_filtered_access.is_compatible(&filtered_access) {
200+
if !current_filtered_access.is_compatible(filtered_access) {
201201
return current_filtered_access
202202
.access
203203
.get_conflicts(&filtered_access.access);

crates/bevy_ecs/src/query/fetch.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ macro_rules! impl_tuple_fetch {
917917
type Item = ($($name::Item,)*);
918918
type State = ($($name::State,)*);
919919

920+
#[allow(clippy::unused_unit)]
920921
unsafe fn init(_world: &World, state: &Self::State, _last_change_tick: u32, _change_tick: u32) -> Self {
921922
let ($($name,)*) = state;
922923
($($name::init(_world, $name, _last_change_tick, _change_tick),)*)
@@ -944,12 +945,14 @@ macro_rules! impl_tuple_fetch {
944945
}
945946

946947
#[inline]
948+
#[allow(clippy::unused_unit)]
947949
unsafe fn table_fetch(&mut self, _table_row: usize) -> Self::Item {
948950
let ($($name,)*) = self;
949951
($($name.table_fetch(_table_row),)*)
950952
}
951953

952954
#[inline]
955+
#[allow(clippy::unused_unit)]
953956
unsafe fn archetype_fetch(&mut self, _archetype_index: usize) -> Self::Item {
954957
let ($($name,)*) = self;
955958
($($name.archetype_fetch(_archetype_index),)*)
@@ -958,6 +961,7 @@ macro_rules! impl_tuple_fetch {
958961

959962
// SAFETY: update_component_access and update_archetype_component_access are called for each item in the tuple
960963
#[allow(non_snake_case)]
964+
#[allow(clippy::unused_unit)]
961965
unsafe impl<$($name: FetchState),*> FetchState for ($($name,)*) {
962966
fn init(_world: &mut World) -> Self {
963967
($($name::init(_world),)*)

crates/bevy_ecs/src/query/iter.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,12 @@ where
290290

291291
// first, iterate from last to first until next item is found
292292
'outer: for i in (0..K).rev() {
293-
match self.cursors[i].next(&self.tables, &self.archetypes, &self.query_state) {
293+
match self.cursors[i].next(self.tables, self.archetypes, self.query_state) {
294294
Some(_) => {
295295
// walk forward up to last element, propagating cursor state forward
296296
for j in (i + 1)..K {
297297
self.cursors[j] = self.cursors[j - 1].clone();
298-
match self.cursors[j].next(
299-
&self.tables,
300-
&self.archetypes,
301-
&self.query_state,
302-
) {
298+
match self.cursors[j].next(self.tables, self.archetypes, self.query_state) {
303299
Some(_) => {}
304300
None if i > 0 => continue 'outer,
305301
None => return None,

crates/bevy_ecs/src/schedule/graph_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn topological_order<Labels: Clone>(
9797
}
9898
current.push(*node);
9999
for dependency in graph.get(node).unwrap().keys() {
100-
if check_if_cycles_and_visit(dependency, &graph, sorted, unvisited, current) {
100+
if check_if_cycles_and_visit(dependency, graph, sorted, unvisited, current) {
101101
return true;
102102
}
103103
}

crates/bevy_ecs/src/system/function_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ where
350350

351351
#[inline]
352352
fn component_access(&self) -> &Access<ComponentId> {
353-
&self.system_meta.component_access_set.combined_access()
353+
self.system_meta.component_access_set.combined_access()
354354
}
355355

356356
#[inline]

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ macro_rules! impl_system_param_tuple {
11581158
type Item = ($($param::Item,)*);
11591159

11601160
#[inline]
1161+
#[allow(clippy::unused_unit)]
11611162
unsafe fn get_param(
11621163
state: &'a mut Self,
11631164
system_meta: &SystemMeta,
@@ -1192,6 +1193,7 @@ macro_rules! impl_system_param_tuple {
11921193
$($param.apply(_world);)*
11931194
}
11941195

1196+
#[allow(clippy::unused_unit)]
11951197
fn default_config() -> ($(<$param as SystemParamState>::Config,)*) {
11961198
($(<$param as SystemParamState>::default_config(),)*)
11971199
}

crates/bevy_gltf/src/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ async fn load_texture<'a>(
369369
}
370370

371371
fn load_material(material: &Material, load_context: &mut LoadContext) -> Handle<StandardMaterial> {
372-
let material_label = material_label(&material);
372+
let material_label = material_label(material);
373373

374374
let pbr = material.pbr_metallic_roughness();
375375

crates/bevy_pbr/src/render_graph/lights_node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ pub fn lights_node_system(
174174
.chunks_exact_mut(point_light_size),
175175
) {
176176
slot.copy_from_slice(bytes_of(&PointLightUniform::new(
177-
&point_light,
178-
&global_transform,
177+
point_light,
178+
global_transform,
179179
)));
180180
}
181181

@@ -184,7 +184,7 @@ pub fn lights_node_system(
184184
data[dir_light_uniform_start..dir_light_uniform_end]
185185
.chunks_exact_mut(dir_light_size),
186186
) {
187-
slot.copy_from_slice(bytes_of(&DirectionalLightUniform::new(&dir_light)));
187+
slot.copy_from_slice(bytes_of(&DirectionalLightUniform::new(dir_light)));
188188
}
189189
},
190190
);

crates/bevy_reflect/bevy_reflect_derive/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ fn impl_struct(
191191
let field_count = active_fields.len();
192192
let field_indices = (0..field_count).collect::<Vec<usize>>();
193193

194-
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
195-
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
194+
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
195+
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
196196
let partial_eq_fn = match reflect_attrs.reflect_partial_eq {
197197
TraitImpl::NotImplemented => quote! {
198198
use #bevy_reflect_path::Struct;
@@ -335,8 +335,8 @@ fn impl_tuple_struct(
335335
let field_count = active_fields.len();
336336
let field_indices = (0..field_count).collect::<Vec<usize>>();
337337

338-
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
339-
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
338+
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
339+
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
340340
let partial_eq_fn = match reflect_attrs.reflect_partial_eq {
341341
TraitImpl::NotImplemented => quote! {
342342
use #bevy_reflect_path::TupleStruct;
@@ -448,9 +448,9 @@ fn impl_value(
448448
bevy_reflect_path: &Path,
449449
reflect_attrs: &ReflectAttrs,
450450
) -> TokenStream {
451-
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
451+
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
452452
let partial_eq_fn = reflect_attrs.get_partial_eq_impl();
453-
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
453+
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
454454

455455
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
456456
TokenStream::from(quote! {

crates/bevy_render/src/mesh/mesh.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -413,34 +413,34 @@ impl Mesh {
413413
for (_, attributes) in self.attributes.iter_mut() {
414414
let indices = indices.iter();
415415
match attributes {
416-
VertexAttributeValues::Float32(vec) => *vec = duplicate(&vec, indices),
417-
VertexAttributeValues::Sint32(vec) => *vec = duplicate(&vec, indices),
418-
VertexAttributeValues::Uint32(vec) => *vec = duplicate(&vec, indices),
419-
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(&vec, indices),
420-
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(&vec, indices),
421-
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(&vec, indices),
422-
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(&vec, indices),
423-
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(&vec, indices),
424-
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(&vec, indices),
425-
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(&vec, indices),
426-
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(&vec, indices),
427-
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(&vec, indices),
428-
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(&vec, indices),
429-
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(&vec, indices),
430-
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(&vec, indices),
431-
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(&vec, indices),
432-
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(&vec, indices),
433-
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(&vec, indices),
434-
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(&vec, indices),
435-
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(&vec, indices),
436-
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(&vec, indices),
437-
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(&vec, indices),
438-
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(&vec, indices),
439-
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(&vec, indices),
440-
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(&vec, indices),
441-
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(&vec, indices),
442-
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(&vec, indices),
443-
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(&vec, indices),
416+
VertexAttributeValues::Float32(vec) => *vec = duplicate(vec, indices),
417+
VertexAttributeValues::Sint32(vec) => *vec = duplicate(vec, indices),
418+
VertexAttributeValues::Uint32(vec) => *vec = duplicate(vec, indices),
419+
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(vec, indices),
420+
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(vec, indices),
421+
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(vec, indices),
422+
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(vec, indices),
423+
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(vec, indices),
424+
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(vec, indices),
425+
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(vec, indices),
426+
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(vec, indices),
427+
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(vec, indices),
428+
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(vec, indices),
429+
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(vec, indices),
430+
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(vec, indices),
431+
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(vec, indices),
432+
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(vec, indices),
433+
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(vec, indices),
434+
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(vec, indices),
435+
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(vec, indices),
436+
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(vec, indices),
437+
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(vec, indices),
438+
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(vec, indices),
439+
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(vec, indices),
440+
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(vec, indices),
441+
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(vec, indices),
442+
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(vec, indices),
443+
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(vec, indices),
444444
}
445445
}
446446
}
@@ -481,7 +481,7 @@ fn remove_resource_save(
481481
index: u64,
482482
) {
483483
if let Some(RenderResourceId::Buffer(buffer)) =
484-
render_resource_context.get_asset_resource(&handle, index)
484+
render_resource_context.get_asset_resource(handle, index)
485485
{
486486
render_resource_context.remove_buffer(buffer);
487487
render_resource_context.remove_asset_resource(handle, index);
@@ -546,7 +546,7 @@ pub fn mesh_resource_provider_system(
546546
buffer_usage: BufferUsage::INDEX,
547547
..Default::default()
548548
},
549-
&data,
549+
data,
550550
);
551551

552552
render_resource_context.set_asset_resource(

crates/bevy_render/src/pipeline/pipeline_compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl PipelineCompiler {
164164
});
165165

166166
let mut layout = render_resource_context.reflect_pipeline_layout(
167-
&shaders,
167+
shaders,
168168
&specialized_descriptor.shader_stages,
169169
true,
170170
);
@@ -252,7 +252,7 @@ impl PipelineCompiler {
252252
render_resource_context.create_render_pipeline(
253253
specialized_pipeline_handle.clone_weak(),
254254
pipelines.get(&specialized_pipeline_handle).unwrap(),
255-
&shaders,
255+
shaders,
256256
);
257257

258258
// track specialized shader pipelines

crates/bevy_render/src/pipeline/vertex_buffer_descriptor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ pub struct VertexAttribute {
5151
/// Internally, `bevy_render` uses hashes to identify vertex attribute names.
5252
pub fn get_vertex_attribute_name_id(name: &str) -> u64 {
5353
let mut hasher = bevy_utils::AHasher::default();
54-
hasher.write(&name.as_bytes());
54+
hasher.write(name.as_bytes());
5555
hasher.finish()
5656
}

crates/bevy_render/src/render_graph/nodes/pass_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ where
237237
let commands = &mut self.commands;
238238
render_context.begin_pass(
239239
&self.descriptor,
240-
&render_resource_bindings,
240+
render_resource_bindings,
241241
&mut |render_pass| {
242242
for render_command in commands.drain(..) {
243243
match render_command {

0 commit comments

Comments
 (0)