Skip to content

Commit

Permalink
Fix nightly clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jul 29, 2021
1 parent ba2916c commit cc2eeec
Show file tree
Hide file tree
Showing 34 changed files with 104 additions and 101 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl AssetServer {
.expect("Asset should exist at this point.");
if let Some(asset_lifecycle) = asset_lifecycles.get(&asset_value.type_uuid()) {
let asset_path =
AssetPath::new_ref(&load_context.path, label.as_ref().map(|l| l.as_str()));
AssetPath::new_ref(load_context.path, label.as_ref().map(|l| l.as_str()));
asset_lifecycle.create_asset(asset_path.into(), asset_value, load_context.version);
} else {
panic!(
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'a> LoadContext<'a> {
}

pub fn path(&self) -> &Path {
&self.path
self.path
}

pub fn has_labeled_asset(&self, label: &str) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_audio/src/audio_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
{
fn play_source(&self, audio_source: &P) {
if let Some(stream_handle) = &self.stream_handle {
let sink = Sink::try_new(&stream_handle).unwrap();
let sink = Sink::try_new(stream_handle).unwrap();
sink.append(audio_source.decoder());
sink.detach();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub(crate) fn entity_labels_system(
}
}

for added_label in labels.labels.difference(&current_labels) {
for added_label in labels.labels.difference(current_labels) {
entity_labels
.label_entities
.entry(added_label.clone())
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ macro_rules! tuple_impl {
}

#[allow(unused_variables, unused_mut)]
#[allow(clippy::unused_unit)]
unsafe fn from_components(mut func: impl FnMut() -> *mut u8) -> Self {
#[allow(non_snake_case)]
let ($(mut $name,)*) = (
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ mod tests {
fn get_added<Com: Component>(world: &mut World) -> Vec<Entity> {
world
.query_filtered::<Entity, Added<Com>>()
.iter(&world)
.iter(world)
.collect::<Vec<Entity>>()
}

Expand Down Expand Up @@ -776,7 +776,7 @@ mod tests {
{
world
.query_filtered::<Entity, F>()
.iter(&world)
.iter(world)
.collect::<Vec<Entity>>()
}

Expand Down Expand Up @@ -863,7 +863,7 @@ mod tests {
fn get_changed(world: &mut World) -> Vec<Entity> {
world
.query_filtered::<Entity, Changed<A>>()
.iter(&world)
.iter(world)
.collect::<Vec<Entity>>()
}
assert_eq!(get_changed(&mut world), vec![e1]);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<T: SparseSetIndex> FilteredAccessSet<T> {
// compatibility
if !filtered_access.access.is_compatible(&self.combined_access) {
for current_filtered_access in self.filtered_accesses.iter() {
if !current_filtered_access.is_compatible(&filtered_access) {
if !current_filtered_access.is_compatible(filtered_access) {
return current_filtered_access
.access
.get_conflicts(&filtered_access.access);
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ macro_rules! impl_tuple_fetch {
type Item = ($($name::Item,)*);
type State = ($($name::State,)*);

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

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

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

// SAFETY: update_component_access and update_archetype_component_access are called for each item in the tuple
#[allow(non_snake_case)]
#[allow(clippy::unused_unit)]
unsafe impl<$($name: FetchState),*> FetchState for ($($name,)*) {
fn init(_world: &mut World) -> Self {
($($name::init(_world),)*)
Expand Down
8 changes: 2 additions & 6 deletions crates/bevy_ecs/src/query/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,12 @@ where

// first, iterate from last to first until next item is found
'outer: for i in (0..K).rev() {
match self.cursors[i].next(&self.tables, &self.archetypes, &self.query_state) {
match self.cursors[i].next(self.tables, self.archetypes, self.query_state) {
Some(_) => {
// walk forward up to last element, propagating cursor state forward
for j in (i + 1)..K {
self.cursors[j] = self.cursors[j - 1].clone();
match self.cursors[j].next(
&self.tables,
&self.archetypes,
&self.query_state,
) {
match self.cursors[j].next(self.tables, self.archetypes, self.query_state) {
Some(_) => {}
None if i > 0 => continue 'outer,
None => return None,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/graph_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn topological_order<Labels: Clone>(
}
current.push(*node);
for dependency in graph.get(node).unwrap().keys() {
if check_if_cycles_and_visit(dependency, &graph, sorted, unvisited, current) {
if check_if_cycles_and_visit(dependency, graph, sorted, unvisited, current) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ where

#[inline]
fn component_access(&self) -> &Access<ComponentId> {
&self.system_meta.component_access_set.combined_access()
self.system_meta.component_access_set.combined_access()
}

#[inline]
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,7 @@ macro_rules! impl_system_param_tuple {
type Item = ($($param::Item,)*);

#[inline]
#[allow(clippy::unused_unit)]
unsafe fn get_param(
state: &'a mut Self,
system_meta: &SystemMeta,
Expand Down Expand Up @@ -1192,6 +1193,7 @@ macro_rules! impl_system_param_tuple {
$($param.apply(_world);)*
}

#[allow(clippy::unused_unit)]
fn default_config() -> ($(<$param as SystemParamState>::Config,)*) {
($(<$param as SystemParamState>::default_config(),)*)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ async fn load_texture<'a>(
}

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

let pbr = material.pbr_metallic_roughness();

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/render_graph/lights_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ pub fn lights_node_system(
.chunks_exact_mut(point_light_size),
) {
slot.copy_from_slice(bytes_of(&PointLightUniform::new(
&point_light,
&global_transform,
point_light,
global_transform,
)));
}

Expand All @@ -184,7 +184,7 @@ pub fn lights_node_system(
data[dir_light_uniform_start..dir_light_uniform_end]
.chunks_exact_mut(dir_light_size),
) {
slot.copy_from_slice(bytes_of(&DirectionalLightUniform::new(&dir_light)));
slot.copy_from_slice(bytes_of(&DirectionalLightUniform::new(dir_light)));
}
},
);
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_reflect/bevy_reflect_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ fn impl_struct(
let field_count = active_fields.len();
let field_indices = (0..field_count).collect::<Vec<usize>>();

let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
let partial_eq_fn = match reflect_attrs.reflect_partial_eq {
TraitImpl::NotImplemented => quote! {
use #bevy_reflect_path::Struct;
Expand Down Expand Up @@ -335,8 +335,8 @@ fn impl_tuple_struct(
let field_count = active_fields.len();
let field_indices = (0..field_count).collect::<Vec<usize>>();

let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);
let partial_eq_fn = match reflect_attrs.reflect_partial_eq {
TraitImpl::NotImplemented => quote! {
use #bevy_reflect_path::TupleStruct;
Expand Down Expand Up @@ -448,9 +448,9 @@ fn impl_value(
bevy_reflect_path: &Path,
reflect_attrs: &ReflectAttrs,
) -> TokenStream {
let hash_fn = reflect_attrs.get_hash_impl(&bevy_reflect_path);
let hash_fn = reflect_attrs.get_hash_impl(bevy_reflect_path);
let partial_eq_fn = reflect_attrs.get_partial_eq_impl();
let serialize_fn = reflect_attrs.get_serialize_impl(&bevy_reflect_path);
let serialize_fn = reflect_attrs.get_serialize_impl(bevy_reflect_path);

let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
TokenStream::from(quote! {
Expand Down
60 changes: 30 additions & 30 deletions crates/bevy_render/src/mesh/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,34 +413,34 @@ impl Mesh {
for (_, attributes) in self.attributes.iter_mut() {
let indices = indices.iter();
match attributes {
VertexAttributeValues::Float32(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(&vec, indices),
VertexAttributeValues::Float32(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(vec, indices),
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(vec, indices),
}
}
}
Expand Down Expand Up @@ -481,7 +481,7 @@ fn remove_resource_save(
index: u64,
) {
if let Some(RenderResourceId::Buffer(buffer)) =
render_resource_context.get_asset_resource(&handle, index)
render_resource_context.get_asset_resource(handle, index)
{
render_resource_context.remove_buffer(buffer);
render_resource_context.remove_asset_resource(handle, index);
Expand Down Expand Up @@ -546,7 +546,7 @@ pub fn mesh_resource_provider_system(
buffer_usage: BufferUsage::INDEX,
..Default::default()
},
&data,
data,
);

render_resource_context.set_asset_resource(
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/pipeline/pipeline_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl PipelineCompiler {
});

let mut layout = render_resource_context.reflect_pipeline_layout(
&shaders,
shaders,
&specialized_descriptor.shader_stages,
true,
);
Expand Down Expand Up @@ -252,7 +252,7 @@ impl PipelineCompiler {
render_resource_context.create_render_pipeline(
specialized_pipeline_handle.clone_weak(),
pipelines.get(&specialized_pipeline_handle).unwrap(),
&shaders,
shaders,
);

// track specialized shader pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ pub struct VertexAttribute {
/// Internally, `bevy_render` uses hashes to identify vertex attribute names.
pub fn get_vertex_attribute_name_id(name: &str) -> u64 {
let mut hasher = bevy_utils::AHasher::default();
hasher.write(&name.as_bytes());
hasher.write(name.as_bytes());
hasher.finish()
}
2 changes: 1 addition & 1 deletion crates/bevy_render/src/render_graph/nodes/pass_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ where
let commands = &mut self.commands;
render_context.begin_pass(
&self.descriptor,
&render_resource_bindings,
render_resource_bindings,
&mut |render_pass| {
for render_command in commands.drain(..) {
match render_command {
Expand Down
Loading

0 comments on commit cc2eeec

Please sign in to comment.