github actions: use stable clippy (#577)

This commit is contained in:
Carter Anderson 2020-09-25 21:34:47 -07:00 committed by GitHub
parent 05db806e15
commit dd07674b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 26 deletions

View File

@ -83,11 +83,6 @@ jobs:
run: cargo +nightly fmt --all -- --check run: cargo +nightly fmt --all -- --check
# type complexity must be ignored because we use huge templates for queries # 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 - name: Run clippy
run: > run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::manual-strip
cargo +nightly clippy
--all-targets
--all-features
--
-D warnings
-A clippy::type_complexity

View File

@ -5,7 +5,7 @@ use std::{io::Cursor, path::Path, sync::Arc};
/// A source of audio data /// A source of audio data
#[derive(Clone)] #[derive(Clone)]
pub struct AudioSource { pub struct AudioSource {
pub bytes: Arc<Vec<u8>>, pub bytes: Arc<[u8]>,
} }
impl AsRef<[u8]> for AudioSource { impl AsRef<[u8]> for AudioSource {
@ -21,7 +21,7 @@ pub struct Mp3Loader;
impl AssetLoader<AudioSource> for Mp3Loader { impl AssetLoader<AudioSource> for Mp3Loader {
fn from_bytes(&self, _asset_path: &Path, bytes: Vec<u8>) -> Result<AudioSource> { fn from_bytes(&self, _asset_path: &Path, bytes: Vec<u8>) -> Result<AudioSource> {
Ok(AudioSource { Ok(AudioSource {
bytes: Arc::new(bytes), bytes: bytes.into(),
}) })
} }

View File

@ -36,7 +36,7 @@ pub enum RenderCommand {
SetBindGroup { SetBindGroup {
index: u32, index: u32,
bind_group: BindGroupId, bind_group: BindGroupId,
dynamic_uniform_indices: Option<Arc<Vec<u32>>>, dynamic_uniform_indices: Option<Arc<[u32]>>,
}, },
DrawIndexed { DrawIndexed {
indices: Range<u32>, indices: Range<u32>,

View File

@ -55,7 +55,7 @@ impl RenderGraph {
let node_id = self.get_node_id(&label)?; let node_id = self.get_node_id(&label)?;
self.nodes self.nodes
.get(&node_id) .get(&node_id)
.ok_or_else(|| RenderGraphError::InvalidNode(label)) .ok_or(RenderGraphError::InvalidNode(label))
} }
pub fn get_node_state_mut( pub fn get_node_state_mut(
@ -66,7 +66,7 @@ impl RenderGraph {
let node_id = self.get_node_id(&label)?; let node_id = self.get_node_id(&label)?;
self.nodes self.nodes
.get_mut(&node_id) .get_mut(&node_id)
.ok_or_else(|| RenderGraphError::InvalidNode(label)) .ok_or(RenderGraphError::InvalidNode(label))
} }
pub fn get_node_id(&self, label: impl Into<NodeLabel>) -> Result<NodeId, RenderGraphError> { pub fn get_node_id(&self, label: impl Into<NodeLabel>) -> Result<NodeId, RenderGraphError> {
@ -77,7 +77,7 @@ impl RenderGraph {
.node_names .node_names
.get(name) .get(name)
.cloned() .cloned()
.ok_or_else(|| RenderGraphError::InvalidNode(label)), .ok_or(RenderGraphError::InvalidNode(label)),
} }
} }

View File

@ -81,7 +81,7 @@ impl Edges {
false false
} }
}) })
.ok_or_else(|| RenderGraphError::UnconnectedNodeInputSlot { .ok_or(RenderGraphError::UnconnectedNodeInputSlot {
input_slot: index, input_slot: index,
node: self.id, node: self.id,
}) })
@ -97,7 +97,7 @@ impl Edges {
false false
} }
}) })
.ok_or_else(|| RenderGraphError::UnconnectedNodeOutputSlot { .ok_or(RenderGraphError::UnconnectedNodeOutputSlot {
output_slot: index, output_slot: index,
node: self.id, node: self.id,
}) })

View File

@ -59,7 +59,7 @@ impl ResourceSlots {
let index = self.get_slot_index(&label)?; let index = self.get_slot_index(&label)?;
self.slots self.slots
.get(index) .get(index)
.ok_or_else(|| RenderGraphError::InvalidNodeSlot(label)) .ok_or(RenderGraphError::InvalidNodeSlot(label))
} }
pub fn get_slot_mut( pub fn get_slot_mut(
@ -70,7 +70,7 @@ impl ResourceSlots {
let index = self.get_slot_index(&label)?; let index = self.get_slot_index(&label)?;
self.slots self.slots
.get_mut(index) .get_mut(index)
.ok_or_else(|| RenderGraphError::InvalidNodeSlot(label)) .ok_or(RenderGraphError::InvalidNodeSlot(label))
} }
pub fn get_slot_index(&self, label: impl Into<SlotLabel>) -> Result<usize, RenderGraphError> { pub fn get_slot_index(&self, label: impl Into<SlotLabel>) -> Result<usize, RenderGraphError> {
@ -83,7 +83,7 @@ impl ResourceSlots {
.enumerate() .enumerate()
.find(|(_i, s)| s.info.name == *name) .find(|(_i, s)| s.info.name == *name)
.map(|(i, _s)| i) .map(|(i, _s)| i)
.ok_or_else(|| RenderGraphError::InvalidNodeSlot(label)), .ok_or(RenderGraphError::InvalidNodeSlot(label)),
} }
} }

View File

@ -13,7 +13,7 @@ use crate::{
}; };
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_ecs::{HecsQuery, ReadOnlyFetch, Resources, World}; use bevy_ecs::{HecsQuery, ReadOnlyFetch, Resources, World};
use std::marker::PhantomData; use std::{marker::PhantomData, ops::Deref};
struct CameraInfo { struct CameraInfo {
name: String, name: String,
@ -281,7 +281,7 @@ where
*bind_group, *bind_group,
dynamic_uniform_indices dynamic_uniform_indices
.as_ref() .as_ref()
.map(|indices| indices.as_slice()), .map(|indices| indices.deref()),
); );
draw_state.set_bind_group(*index, *bind_group); draw_state.set_bind_group(*index, *bind_group);
} }

View File

@ -18,8 +18,8 @@ pub struct IndexedBindGroupEntry {
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug)]
pub struct BindGroup { pub struct BindGroup {
pub id: BindGroupId, pub id: BindGroupId,
pub indexed_bindings: Arc<Vec<IndexedBindGroupEntry>>, pub indexed_bindings: Arc<[IndexedBindGroupEntry]>,
pub dynamic_uniform_indices: Option<Arc<Vec<u32>>>, pub dynamic_uniform_indices: Option<Arc<[u32]>>,
} }
impl BindGroup { impl BindGroup {
@ -94,11 +94,11 @@ impl BindGroupBuilder {
self.indexed_bindings.sort_by_key(|i| i.index); self.indexed_bindings.sort_by_key(|i| i.index);
BindGroup { BindGroup {
id: BindGroupId(self.hasher.finish()), 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() { dynamic_uniform_indices: if self.dynamic_uniform_indices.is_empty() {
None None
} else { } else {
Some(Arc::new(self.dynamic_uniform_indices)) Some(self.dynamic_uniform_indices.into())
}, },
} }
} }

View File

@ -96,7 +96,7 @@ impl SceneSpawner {
let scenes = resources.get::<Assets<Scene>>().unwrap(); let scenes = resources.get::<Assets<Scene>>().unwrap();
let scene = scenes let scene = scenes
.get(&scene_handle) .get(&scene_handle)
.ok_or_else(|| SceneSpawnError::NonExistentScene { .ok_or(SceneSpawnError::NonExistentScene {
handle: scene_handle, handle: scene_handle,
})?; })?;
@ -108,7 +108,7 @@ impl SceneSpawner {
for component in scene_entity.components.iter() { for component in scene_entity.components.iter() {
let component_registration = component_registry let component_registration = component_registry
.get_with_name(&component.type_name) .get_with_name(&component.type_name)
.ok_or_else(|| SceneSpawnError::UnregisteredComponent { .ok_or(SceneSpawnError::UnregisteredComponent {
type_name: component.type_name.to_string(), type_name: component.type_name.to_string(),
})?; })?;
if world.has_component_type(entity, component_registration.ty) { if world.has_component_type(entity, component_registration.ty) {