From 7b336fd779d8c016e79b063bc282e3495b071b84 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Fri, 30 Jul 2021 03:17:27 +0000 Subject: [PATCH] fix nightly clippy lints (#2568) Fix new nightly clippy lints on `pipelined-rendering` --- crates/bevy_asset/src/asset_server.rs | 11 ++-- pipelined/bevy_pbr2/src/render/mod.rs | 18 +++---- pipelined/bevy_render2/src/mesh/mesh/mod.rs | 58 ++++++++++----------- pipelined/bevy_render2/src/renderer/mod.rs | 4 +- pipelined/bevy_render2/src/shader/shader.rs | 6 +-- pipelined/bevy_render2/src/texture/image.rs | 2 +- 6 files changed, 47 insertions(+), 52 deletions(-) diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index f46b96ed7b..9847e24254 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -53,7 +53,7 @@ pub struct AssetServerInternal { pub(crate) asset_ref_counter: AssetRefCounter, pub(crate) asset_sources: Arc>>, pub(crate) asset_lifecycles: Arc>>>, - loaders: RwLock>>>, + loaders: RwLock>>, extension_to_loader_index: RwLock>, handle_to_path: Arc>>>, task_pool: TaskPool, @@ -112,7 +112,7 @@ impl AssetServer { .write() .insert(extension.to_string(), loader_index); } - loaders.push(Arc::new(Box::new(loader))); + loaders.push(Arc::new(loader)); } pub fn watch_for_changes(&self) -> Result<(), AssetServerError> { @@ -130,10 +130,7 @@ impl AssetServer { HandleUntyped::strong(id.into(), sender) } - fn get_asset_loader( - &self, - extension: &str, - ) -> Result>, AssetServerError> { + fn get_asset_loader(&self, extension: &str) -> Result, AssetServerError> { let index = { // scope map to drop lock as soon as possible let map = self.server.extension_to_loader_index.read(); @@ -149,7 +146,7 @@ impl AssetServer { fn get_path_asset_loader>( &self, path: P, - ) -> Result>, AssetServerError> { + ) -> Result, AssetServerError> { let s = path .as_ref() .file_name() diff --git a/pipelined/bevy_pbr2/src/render/mod.rs b/pipelined/bevy_pbr2/src/render/mod.rs index 8c54071eb1..31e160d835 100644 --- a/pipelined/bevy_pbr2/src/render/mod.rs +++ b/pipelined/bevy_pbr2/src/render/mod.rs @@ -631,39 +631,37 @@ pub fn queue_meshes( }, BindGroupEntry { binding: 1, - resource: BindingResource::TextureView( - &base_color_texture_view, - ), + resource: BindingResource::TextureView(base_color_texture_view), }, BindGroupEntry { binding: 2, - resource: BindingResource::Sampler(&base_color_sampler), + resource: BindingResource::Sampler(base_color_sampler), }, BindGroupEntry { binding: 3, - resource: BindingResource::TextureView(&emissive_texture_view), + resource: BindingResource::TextureView(emissive_texture_view), }, BindGroupEntry { binding: 4, - resource: BindingResource::Sampler(&emissive_sampler), + resource: BindingResource::Sampler(emissive_sampler), }, BindGroupEntry { binding: 5, resource: BindingResource::TextureView( - &metallic_roughness_texture_view, + metallic_roughness_texture_view, ), }, BindGroupEntry { binding: 6, - resource: BindingResource::Sampler(&metallic_roughness_sampler), + resource: BindingResource::Sampler(metallic_roughness_sampler), }, BindGroupEntry { binding: 7, - resource: BindingResource::TextureView(&occlusion_texture_view), + resource: BindingResource::TextureView(occlusion_texture_view), }, BindGroupEntry { binding: 8, - resource: BindingResource::Sampler(&occlusion_sampler), + resource: BindingResource::Sampler(occlusion_sampler), }, ], label: None, diff --git a/pipelined/bevy_render2/src/mesh/mesh/mod.rs b/pipelined/bevy_render2/src/mesh/mesh/mod.rs index 57f5ed80d4..18e22ab08d 100644 --- a/pipelined/bevy_render2/src/mesh/mesh/mod.rs +++ b/pipelined/bevy_render2/src/mesh/mesh/mod.rs @@ -210,34 +210,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), } } } @@ -560,7 +560,7 @@ impl RenderAsset for Mesh { let index_info = mesh.get_index_buffer_bytes().map(|data| GpuIndexInfo { buffer: render_device.create_buffer_with_data(&BufferInitDescriptor { usage: BufferUsage::INDEX, - contents: &data, + contents: data, label: None, }), count: mesh.indices().unwrap().len() as u32, diff --git a/pipelined/bevy_render2/src/renderer/mod.rs b/pipelined/bevy_render2/src/renderer/mod.rs index b53a76e92b..91bb42a08b 100644 --- a/pipelined/bevy_render2/src/renderer/mod.rs +++ b/pipelined/bevy_render2/src/renderer/mod.rs @@ -37,7 +37,7 @@ pub async fn initialize_renderer( let instance = wgpu::Instance::new(backends); let adapter = instance - .request_adapter(&request_adapter_options) + .request_adapter(request_adapter_options) .await .expect("Unable to find a GPU! Make sure you have installed required drivers!"); @@ -55,7 +55,7 @@ pub async fn initialize_renderer( let trace_path = None; let (device, queue) = adapter - .request_device(&device_descriptor, trace_path) + .request_device(device_descriptor, trace_path) .await .unwrap(); let device = Arc::new(device); diff --git a/pipelined/bevy_render2/src/shader/shader.rs b/pipelined/bevy_render2/src/shader/shader.rs index b27539dec9..ace300da63 100644 --- a/pipelined/bevy_render2/src/shader/shader.rs +++ b/pipelined/bevy_render2/src/shader/shader.rs @@ -66,13 +66,13 @@ impl Shader { pub fn reflect(&self) -> Result { let module = match &self { // TODO: process macros here - Shader::Wgsl(source) => naga::front::wgsl::parse_str(&source)?, + Shader::Wgsl(source) => naga::front::wgsl::parse_str(source)?, Shader::Glsl(source) => { let mut entry_points = HashMap::default(); entry_points.insert("vertex".to_string(), ShaderStage::Vertex); entry_points.insert("fragment".to_string(), ShaderStage::Fragment); naga::front::glsl::parse_str( - &source, + source, &naga::front::glsl::Options { entry_points, defines: Default::default(), @@ -80,7 +80,7 @@ impl Shader { )? } Shader::SpirV(source) => naga::front::spv::parse_u8_slice( - &source, + source, &naga::front::spv::Options { adjust_coordinate_space: false, ..naga::front::spv::Options::default() diff --git a/pipelined/bevy_render2/src/texture/image.rs b/pipelined/bevy_render2/src/texture/image.rs index 196185ddfa..6141669472 100644 --- a/pipelined/bevy_render2/src/texture/image.rs +++ b/pipelined/bevy_render2/src/texture/image.rs @@ -89,7 +89,7 @@ impl Image { ); for current_pixel in value.data.chunks_exact_mut(pixel.len()) { - current_pixel.copy_from_slice(&pixel); + current_pixel.copy_from_slice(pixel); } value }