diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 065a7e3d50d34..6189a6406a269 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,11 +83,6 @@ jobs: run: cargo +nightly fmt --all -- --check # type complexity must be ignored because we use huge templates for queries + # -A clippy::manual-strip: strip_prefix support was added in 1.45. we want to support earlier rust versions - name: Run clippy - run: > - cargo +nightly clippy - --all-targets - --all-features - -- - -D warnings - -A clippy::type_complexity + run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::manual-strip diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 3635d802dcc59..bd3356dc92feb 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -5,7 +5,7 @@ use std::{io::Cursor, path::Path, sync::Arc}; /// A source of audio data #[derive(Clone)] pub struct AudioSource { - pub bytes: Arc>, + pub bytes: Arc<[u8]>, } impl AsRef<[u8]> for AudioSource { @@ -21,7 +21,7 @@ pub struct Mp3Loader; impl AssetLoader for Mp3Loader { fn from_bytes(&self, _asset_path: &Path, bytes: Vec) -> Result { Ok(AudioSource { - bytes: Arc::new(bytes), + bytes: bytes.into(), }) } diff --git a/crates/bevy_render/src/draw.rs b/crates/bevy_render/src/draw.rs index 7ac303498e652..a54db24fcee3c 100644 --- a/crates/bevy_render/src/draw.rs +++ b/crates/bevy_render/src/draw.rs @@ -36,7 +36,7 @@ pub enum RenderCommand { SetBindGroup { index: u32, bind_group: BindGroupId, - dynamic_uniform_indices: Option>>, + dynamic_uniform_indices: Option>, }, DrawIndexed { indices: Range, diff --git a/crates/bevy_render/src/render_graph/graph.rs b/crates/bevy_render/src/render_graph/graph.rs index b8d2bf0f80016..983b6fcd0a3a2 100644 --- a/crates/bevy_render/src/render_graph/graph.rs +++ b/crates/bevy_render/src/render_graph/graph.rs @@ -55,7 +55,7 @@ impl RenderGraph { let node_id = self.get_node_id(&label)?; self.nodes .get(&node_id) - .ok_or_else(|| RenderGraphError::InvalidNode(label)) + .ok_or(RenderGraphError::InvalidNode(label)) } pub fn get_node_state_mut( @@ -66,7 +66,7 @@ impl RenderGraph { let node_id = self.get_node_id(&label)?; self.nodes .get_mut(&node_id) - .ok_or_else(|| RenderGraphError::InvalidNode(label)) + .ok_or(RenderGraphError::InvalidNode(label)) } pub fn get_node_id(&self, label: impl Into) -> Result { @@ -77,7 +77,7 @@ impl RenderGraph { .node_names .get(name) .cloned() - .ok_or_else(|| RenderGraphError::InvalidNode(label)), + .ok_or(RenderGraphError::InvalidNode(label)), } } diff --git a/crates/bevy_render/src/render_graph/node.rs b/crates/bevy_render/src/render_graph/node.rs index 35ca29754032d..06f4dffdc76cf 100644 --- a/crates/bevy_render/src/render_graph/node.rs +++ b/crates/bevy_render/src/render_graph/node.rs @@ -81,7 +81,7 @@ impl Edges { false } }) - .ok_or_else(|| RenderGraphError::UnconnectedNodeInputSlot { + .ok_or(RenderGraphError::UnconnectedNodeInputSlot { input_slot: index, node: self.id, }) @@ -97,7 +97,7 @@ impl Edges { false } }) - .ok_or_else(|| RenderGraphError::UnconnectedNodeOutputSlot { + .ok_or(RenderGraphError::UnconnectedNodeOutputSlot { output_slot: index, node: self.id, }) diff --git a/crates/bevy_render/src/render_graph/node_slot.rs b/crates/bevy_render/src/render_graph/node_slot.rs index 9ad6ca3d61f04..e25fc95e6b525 100644 --- a/crates/bevy_render/src/render_graph/node_slot.rs +++ b/crates/bevy_render/src/render_graph/node_slot.rs @@ -59,7 +59,7 @@ impl ResourceSlots { let index = self.get_slot_index(&label)?; self.slots .get(index) - .ok_or_else(|| RenderGraphError::InvalidNodeSlot(label)) + .ok_or(RenderGraphError::InvalidNodeSlot(label)) } pub fn get_slot_mut( @@ -70,7 +70,7 @@ impl ResourceSlots { let index = self.get_slot_index(&label)?; self.slots .get_mut(index) - .ok_or_else(|| RenderGraphError::InvalidNodeSlot(label)) + .ok_or(RenderGraphError::InvalidNodeSlot(label)) } pub fn get_slot_index(&self, label: impl Into) -> Result { @@ -83,7 +83,7 @@ impl ResourceSlots { .enumerate() .find(|(_i, s)| s.info.name == *name) .map(|(i, _s)| i) - .ok_or_else(|| RenderGraphError::InvalidNodeSlot(label)), + .ok_or(RenderGraphError::InvalidNodeSlot(label)), } } diff --git a/crates/bevy_render/src/render_graph/nodes/pass_node.rs b/crates/bevy_render/src/render_graph/nodes/pass_node.rs index 678dd30a34408..954a997a0496d 100644 --- a/crates/bevy_render/src/render_graph/nodes/pass_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/pass_node.rs @@ -13,7 +13,7 @@ use crate::{ }; use bevy_asset::{Assets, Handle}; use bevy_ecs::{HecsQuery, ReadOnlyFetch, Resources, World}; -use std::marker::PhantomData; +use std::{marker::PhantomData, ops::Deref}; struct CameraInfo { name: String, @@ -281,7 +281,7 @@ where *bind_group, dynamic_uniform_indices .as_ref() - .map(|indices| indices.as_slice()), + .map(|indices| indices.deref()), ); draw_state.set_bind_group(*index, *bind_group); } diff --git a/crates/bevy_render/src/renderer/render_resource/bind_group.rs b/crates/bevy_render/src/renderer/render_resource/bind_group.rs index c92849a00f20f..2e4f264e585d1 100644 --- a/crates/bevy_render/src/renderer/render_resource/bind_group.rs +++ b/crates/bevy_render/src/renderer/render_resource/bind_group.rs @@ -18,8 +18,8 @@ pub struct IndexedBindGroupEntry { #[derive(Clone, Eq, PartialEq, Debug)] pub struct BindGroup { pub id: BindGroupId, - pub indexed_bindings: Arc>, - pub dynamic_uniform_indices: Option>>, + pub indexed_bindings: Arc<[IndexedBindGroupEntry]>, + pub dynamic_uniform_indices: Option>, } impl BindGroup { @@ -94,11 +94,11 @@ impl BindGroupBuilder { self.indexed_bindings.sort_by_key(|i| i.index); BindGroup { id: BindGroupId(self.hasher.finish()), - indexed_bindings: Arc::new(self.indexed_bindings), + indexed_bindings: self.indexed_bindings.into(), dynamic_uniform_indices: if self.dynamic_uniform_indices.is_empty() { None } else { - Some(Arc::new(self.dynamic_uniform_indices)) + Some(self.dynamic_uniform_indices.into()) }, } } diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index 53c1541db7eec..4c581d91569b5 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -96,7 +96,7 @@ impl SceneSpawner { let scenes = resources.get::>().unwrap(); let scene = scenes .get(&scene_handle) - .ok_or_else(|| SceneSpawnError::NonExistentScene { + .ok_or(SceneSpawnError::NonExistentScene { handle: scene_handle, })?; @@ -108,7 +108,7 @@ impl SceneSpawner { for component in scene_entity.components.iter() { let component_registration = component_registry .get_with_name(&component.type_name) - .ok_or_else(|| SceneSpawnError::UnregisteredComponent { + .ok_or(SceneSpawnError::UnregisteredComponent { type_name: component.type_name.to_string(), })?; if world.has_component_type(entity, component_registration.ty) {