fix clippy

This commit is contained in:
Carter Anderson 2021-07-01 18:05:20 -07:00
parent bc769d9641
commit ac6b27925e
20 changed files with 1315 additions and 1299 deletions

View File

@ -1,7 +1,6 @@
use serde::Deserialize; use crate::app::{App, AppExit};
use crate::{app::AppExit, AppBuilder};
use bevy_ecs::system::IntoSystem; use bevy_ecs::system::IntoSystem;
use serde::Deserialize;
/// Configuration for automated testing on CI /// Configuration for automated testing on CI
#[derive(Deserialize)] #[derive(Deserialize)]
@ -23,16 +22,15 @@ fn ci_testing_exit_after(
*current_frame += 1; *current_frame += 1;
} }
pub(crate) fn setup_app(app_builder: &mut AppBuilder) -> &mut AppBuilder { pub(crate) fn setup_app(app: &mut App) -> &mut App {
let filename = let filename =
std::env::var("CI_TESTING_CONFIG").unwrap_or_else(|_| "ci_testing_config.ron".to_string()); std::env::var("CI_TESTING_CONFIG").unwrap_or_else(|_| "ci_testing_config.ron".to_string());
let config: CiTestingConfig = ron::from_str( let config: CiTestingConfig = ron::from_str(
&std::fs::read_to_string(filename).expect("error reading CI testing configuration file"), &std::fs::read_to_string(filename).expect("error reading CI testing configuration file"),
) )
.expect("error deserializing CI testing configuration file"); .expect("error deserializing CI testing configuration file");
app_builder app.insert_resource(config)
.insert_resource(config)
.add_system(ci_testing_exit_after.system()); .add_system(ci_testing_exit_after.system());
app_builder app
} }

View File

@ -428,6 +428,11 @@ impl Entities {
/// Allocates space for entities previously reserved with `reserve_entity` or /// Allocates space for entities previously reserved with `reserve_entity` or
/// `reserve_entities`, then initializes each one using the supplied function. /// `reserve_entities`, then initializes each one using the supplied function.
///
/// # Safety
/// Flush _must_ set the entity location to the correct ArchetypeId for the given Entity
/// each time init is called. This _can_ be ArchetypeId::invalid(), provided the Entity has
/// not been assigned to an Archetype.
pub unsafe fn flush(&mut self, mut init: impl FnMut(Entity, &mut EntityLocation)) { pub unsafe fn flush(&mut self, mut init: impl FnMut(Entity, &mut EntityLocation)) {
let free_cursor = self.free_cursor.get_mut(); let free_cursor = self.free_cursor.get_mut();
let current_free_cursor = *free_cursor; let current_free_cursor = *free_cursor;

View File

@ -15,7 +15,7 @@ impl RawWindowHandleWrapper {
/// have constraints on where/how this handle can be used. For example, some platforms don't support doing window /// have constraints on where/how this handle can be used. For example, some platforms don't support doing window
/// operations off of the main thread. The caller must ensure the [`RawWindowHandle`] is only used in valid contexts. /// operations off of the main thread. The caller must ensure the [`RawWindowHandle`] is only used in valid contexts.
pub unsafe fn get_handle(&self) -> HasRawWindowHandleWrapper { pub unsafe fn get_handle(&self) -> HasRawWindowHandleWrapper {
HasRawWindowHandleWrapper(self.0.clone()) HasRawWindowHandleWrapper(self.0)
} }
} }
@ -32,6 +32,6 @@ pub struct HasRawWindowHandleWrapper(RawWindowHandle);
// SAFE: the caller has validated that this is a valid context to get RawWindowHandle // SAFE: the caller has validated that this is a valid context to get RawWindowHandle
unsafe impl HasRawWindowHandle for HasRawWindowHandleWrapper { unsafe impl HasRawWindowHandle for HasRawWindowHandleWrapper {
fn raw_window_handle(&self) -> RawWindowHandle { fn raw_window_handle(&self) -> RawWindowHandle {
self.0.clone() self.0
} }
} }

View File

@ -246,11 +246,7 @@ impl EmitOptions {
// For testing purposes, we can optionally generate type layout // For testing purposes, we can optionally generate type layout
// information using the type-layout crate. // information using the type-layout crate.
let type_layout_derive = if cfg!(feature = "test_type_layout") { let type_layout_derive = quote!();
quote!(#[derive(::type_layout::TypeLayout)])
} else {
quote!()
};
quote! { quote! {
#[allow(non_snake_case)] #[allow(non_snake_case)]

View File

@ -1,3 +1,5 @@
#![allow(clippy::all)]
/*! /*!
[![GitHub CI Status](https://github.com/LPGhatguy/crevice/workflows/CI/badge.svg)](https://github.com/LPGhatguy/crevice/actions) [![GitHub CI Status](https://github.com/LPGhatguy/crevice/workflows/CI/badge.svg)](https://github.com/LPGhatguy/crevice/actions)
[![crevice on crates.io](https://img.shields.io/crates/v/crevice.svg)](https://crates.io/crates/crevice) [![crevice on crates.io](https://img.shields.io/crates/v/crevice.svg)](https://crates.io/crates/crevice)

View File

@ -9,7 +9,7 @@ fn main() {
fn setup( fn setup(
mut commands: Commands, mut commands: Commands,
asset_server: Res<AssetServer>, _asset_server: Res<AssetServer>,
// mut materials: ResMut<Assets<ColorMaterial>>, // mut materials: ResMut<Assets<ColorMaterial>>,
) { ) {
// let texture_handle = asset_server.load("branding/icon.png"); // let texture_handle = asset_server.load("branding/icon.png");

View File

@ -13,7 +13,7 @@ use bevy::{
use rand::Rng; use rand::Rng;
const BIRDS_PER_SECOND: u32 = 10000; const BIRDS_PER_SECOND: u32 = 10000;
const BASE_COLOR: Color = Color::rgb(5.0, 5.0, 5.0); const _BASE_COLOR: Color = Color::rgb(5.0, 5.0, 5.0);
const GRAVITY: f32 = -9.8 * 100.0; const GRAVITY: f32 = -9.8 * 100.0;
const MAX_VELOCITY: f32 = 750.; const MAX_VELOCITY: f32 = 750.;
const BIRD_SCALE: f32 = 0.15; const BIRD_SCALE: f32 = 0.15;
@ -66,8 +66,8 @@ struct BirdTexture(Handle<Image>);
fn setup( fn setup(
mut commands: Commands, mut commands: Commands,
window: Res<WindowDescriptor>, _window: Res<WindowDescriptor>,
mut counter: ResMut<BevyCounter>, _counter: ResMut<BevyCounter>,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
) { ) {
// spawn_birds(&mut commands, &window, &mut counter, 10); // spawn_birds(&mut commands, &window, &mut counter, 10);
@ -129,7 +129,7 @@ fn setup(
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn mouse_handler( fn mouse_handler(
mut commands: Commands, mut commands: Commands,
asset_server: Res<AssetServer>, _asset_server: Res<AssetServer>,
time: Res<Time>, time: Res<Time>,
mouse_button_input: Res<Input<MouseButton>>, mouse_button_input: Res<Input<MouseButton>>,
window: Res<WindowDescriptor>, window: Res<WindowDescriptor>,

View File

@ -19,7 +19,7 @@ use bevy_render2::{
pub mod draw_3d_graph { pub mod draw_3d_graph {
pub mod node { pub mod node {
pub const SHADOW_PASS: &'static str = "shadow_pass"; pub const SHADOW_PASS: &str = "shadow_pass";
} }
} }

View File

@ -190,7 +190,7 @@ pub fn extract_lights(
intensity: light.intensity, intensity: light.intensity,
range: light.range, range: light.range,
radius: light.radius, radius: light.radius,
transform: transform.clone(), transform: *transform,
}); });
} }
} }
@ -341,8 +341,8 @@ pub fn prepare_lights(
// premultiply color by intensity // premultiply color by intensity
// we don't use the alpha at all, so no reason to multiply only [0..3] // we don't use the alpha at all, so no reason to multiply only [0..3]
color: (light.color.as_rgba_linear() * light.intensity).into(), color: (light.color.as_rgba_linear() * light.intensity).into(),
radius: light.radius.into(), radius: light.radius,
position: light.transform.translation.into(), position: light.transform.translation,
inverse_square_range: 1.0 / (light.range * light.range), inverse_square_range: 1.0 / (light.range * light.range),
near: 0.1, near: 0.1,
far: light.range, far: light.range,
@ -360,7 +360,7 @@ pub fn prepare_lights(
aspect: TextureAspect::All, aspect: TextureAspect::All,
base_mip_level: 0, base_mip_level: 0,
mip_level_count: None, mip_level_count: None,
base_array_layer: 0 as u32, base_array_layer: 0,
array_layer_count: None, array_layer_count: None,
}); });
@ -412,7 +412,7 @@ impl Node for ShadowPassNode {
world: &World, world: &World,
) -> Result<(), NodeRunError> { ) -> Result<(), NodeRunError> {
let view_entity = graph.get_input_entity(Self::IN_VIEW)?; let view_entity = graph.get_input_entity(Self::IN_VIEW)?;
if let Some(view_lights) = self.main_view_query.get_manual(world, view_entity).ok() { if let Ok(view_lights) = self.main_view_query.get_manual(world, view_entity) {
for view_light_entity in view_lights.lights.iter().copied() { for view_light_entity in view_lights.lights.iter().copied() {
let (view_light, shadow_phase) = self let (view_light, shadow_phase) = self
.view_light_query .view_light_query

View File

@ -340,10 +340,10 @@ impl FromWorld for PbrShaders {
}; };
PbrShaders { PbrShaders {
pipeline, pipeline,
shader_module,
view_layout, view_layout,
material_layout, material_layout,
mesh_layout, mesh_layout,
shader_module,
dummy_white_gpu_image, dummy_white_gpu_image,
} }
} }
@ -466,6 +466,7 @@ fn image_handle_to_view_sampler<'a>(
) )
} }
#[allow(clippy::too_many_arguments)]
pub fn queue_meshes( pub fn queue_meshes(
mut commands: Commands, mut commands: Commands,
draw_functions: Res<DrawFunctions>, draw_functions: Res<DrawFunctions>,
@ -488,7 +489,7 @@ pub fn queue_meshes(
) { ) {
let mesh_meta = mesh_meta.into_inner(); let mesh_meta = mesh_meta.into_inner();
if view_meta.uniforms.len() == 0 { if view_meta.uniforms.is_empty() {
return; return;
} }

View File

@ -80,7 +80,7 @@ fn extract_cameras(
}, },
ExtractedView { ExtractedView {
projection: camera.projection_matrix, projection: camera.projection_matrix,
transform: transform.clone(), transform: *transform,
width: window.physical_width(), width: window.physical_width(),
height: window.physical_height(), height: window.physical_height(),
}, },

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -26,31 +26,31 @@ use wgpu::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, Texture
// 3. "sub graph" modules should be nested beneath their parent graph module // 3. "sub graph" modules should be nested beneath their parent graph module
pub mod node { pub mod node {
pub const MAIN_PASS_DEPENDENCIES: &'static str = "main_pass_dependencies"; pub const MAIN_PASS_DEPENDENCIES: &str = "main_pass_dependencies";
pub const MAIN_PASS_DRIVER: &'static str = "main_pass_driver"; pub const MAIN_PASS_DRIVER: &str = "main_pass_driver";
pub const VIEW: &'static str = "view"; pub const VIEW: &str = "view";
} }
pub mod draw_2d_graph { pub mod draw_2d_graph {
pub const NAME: &'static str = "draw_2d"; pub const NAME: &str = "draw_2d";
pub mod input { pub mod input {
pub const VIEW_ENTITY: &'static str = "view_entity"; pub const VIEW_ENTITY: &str = "view_entity";
pub const RENDER_TARGET: &'static str = "render_target"; pub const RENDER_TARGET: &str = "render_target";
} }
pub mod node { pub mod node {
pub const MAIN_PASS: &'static str = "main_pass"; pub const MAIN_PASS: &str = "main_pass";
} }
} }
pub mod draw_3d_graph { pub mod draw_3d_graph {
pub const NAME: &'static str = "draw_3d"; pub const NAME: &str = "draw_3d";
pub mod input { pub mod input {
pub const VIEW_ENTITY: &'static str = "view_entity"; pub const VIEW_ENTITY: &str = "view_entity";
pub const RENDER_TARGET: &'static str = "render_target"; pub const RENDER_TARGET: &str = "render_target";
pub const DEPTH: &'static str = "depth"; pub const DEPTH: &str = "depth";
} }
pub mod node { pub mod node {
pub const MAIN_PASS: &'static str = "main_pass"; pub const MAIN_PASS: &str = "main_pass";
} }
} }

View File

@ -493,6 +493,13 @@ impl Indices {
Indices::U32(vec) => vec.len(), Indices::U32(vec) => vec.len(),
} }
} }
pub fn is_empty(&self) -> bool {
match self {
Indices::U16(vec) => vec.is_empty(),
Indices::U32(vec) => vec.is_empty(),
}
}
} }
enum IndicesIter<'a> { enum IndicesIter<'a> {
U16(std::slice::Iter<'a, u16>), U16(std::slice::Iter<'a, u16>),

View File

@ -65,7 +65,7 @@ impl<'a> RenderGraphContext<'a> {
let label = label.into(); let label = label.into();
match self.get_input(label.clone())? { match self.get_input(label.clone())? {
SlotValue::TextureView(value) => Ok(value), SlotValue::TextureView(value) => Ok(value),
value @ _ => Err(InputSlotError::MismatchedSlotType { value => Err(InputSlotError::MismatchedSlotType {
label, label,
actual: value.slot_type(), actual: value.slot_type(),
expected: SlotType::TextureView, expected: SlotType::TextureView,
@ -80,7 +80,7 @@ impl<'a> RenderGraphContext<'a> {
let label = label.into(); let label = label.into();
match self.get_input(label.clone())? { match self.get_input(label.clone())? {
SlotValue::Sampler(value) => Ok(value), SlotValue::Sampler(value) => Ok(value),
value @ _ => Err(InputSlotError::MismatchedSlotType { value => Err(InputSlotError::MismatchedSlotType {
label, label,
actual: value.slot_type(), actual: value.slot_type(),
expected: SlotType::Sampler, expected: SlotType::Sampler,
@ -92,7 +92,7 @@ impl<'a> RenderGraphContext<'a> {
let label = label.into(); let label = label.into();
match self.get_input(label.clone())? { match self.get_input(label.clone())? {
SlotValue::Buffer(value) => Ok(value), SlotValue::Buffer(value) => Ok(value),
value @ _ => Err(InputSlotError::MismatchedSlotType { value => Err(InputSlotError::MismatchedSlotType {
label, label,
actual: value.slot_type(), actual: value.slot_type(),
expected: SlotType::Buffer, expected: SlotType::Buffer,
@ -104,7 +104,7 @@ impl<'a> RenderGraphContext<'a> {
let label = label.into(); let label = label.into();
match self.get_input(label.clone())? { match self.get_input(label.clone())? {
SlotValue::Entity(value) => Ok(*value), SlotValue::Entity(value) => Ok(*value),
value @ _ => Err(InputSlotError::MismatchedSlotType { value => Err(InputSlotError::MismatchedSlotType {
label, label,
actual: value.slot_type(), actual: value.slot_type(),
expected: SlotType::Entity, expected: SlotType::Entity,
@ -122,7 +122,7 @@ impl<'a> RenderGraphContext<'a> {
let slot_index = self let slot_index = self
.output_info() .output_info()
.get_slot_index(label.clone()) .get_slot_index(label.clone())
.ok_or(OutputSlotError::InvalidSlot(label.clone()))?; .ok_or_else(|| OutputSlotError::InvalidSlot(label.clone()))?;
let slot = self let slot = self
.output_info() .output_info()
.get_slot(slot_index) .get_slot(slot_index)
@ -147,7 +147,7 @@ impl<'a> RenderGraphContext<'a> {
let sub_graph = self let sub_graph = self
.graph .graph
.get_sub_graph(&name) .get_sub_graph(&name)
.ok_or(RunSubGraphError::MissingSubGraph(name.clone()))?; .ok_or_else(|| RunSubGraphError::MissingSubGraph(name.clone()))?;
if let Some(input_node) = sub_graph.input_node() { if let Some(input_node) = sub_graph.input_node() {
for (i, input_slot) in input_node.input_slots.iter().enumerate() { for (i, input_slot) in input_node.input_slots.iter().enumerate() {
if let Some(input_value) = inputs.get(i) { if let Some(input_value) = inputs.get(i) {
@ -168,11 +168,9 @@ impl<'a> RenderGraphContext<'a> {
}); });
} }
} }
} else { } else if !inputs.is_empty() {
if !inputs.is_empty() {
return Err(RunSubGraphError::SubGraphHasNoInputs(name)); return Err(RunSubGraphError::SubGraphHasNoInputs(name));
} }
}
self.run_sub_graphs.push(RunSubGraph { name, inputs }); self.run_sub_graphs.push(RunSubGraph { name, inputs });

View File

@ -194,15 +194,12 @@ impl RenderGraph {
let output_slot = output_node_state let output_slot = output_node_state
.output_slots .output_slots
.get_slot(output_index) .get_slot(output_index)
.ok_or_else(|| { .ok_or(RenderGraphError::InvalidOutputNodeSlot(SlotLabel::Index(
RenderGraphError::InvalidOutputNodeSlot(SlotLabel::Index(output_index)) output_index,
})?; )))?;
let input_slot = input_node_state let input_slot = input_node_state.input_slots.get_slot(input_index).ok_or(
.input_slots RenderGraphError::InvalidInputNodeSlot(SlotLabel::Index(input_index)),
.get_slot(input_index) )?;
.ok_or_else(|| {
RenderGraphError::InvalidInputNodeSlot(SlotLabel::Index(input_index))
})?;
if let Some(Edge::SlotEdge { if let Some(Edge::SlotEdge {
output_node: current_output_node, output_node: current_output_node,

View File

@ -49,6 +49,11 @@ impl<T: AsStd140> UniformVec<T> {
self.values.len() self.values.len()
} }
#[inline]
pub fn is_empty(&self) -> bool {
self.values.is_empty()
}
#[inline] #[inline]
pub fn capacity(&self) -> usize { pub fn capacity(&self) -> usize {
self.capacity self.capacity
@ -155,6 +160,11 @@ impl<T: AsStd140> DynamicUniformVec<T> {
self.uniform_vec.len() self.uniform_vec.len()
} }
#[inline]
pub fn is_empty(&self) -> bool {
self.uniform_vec.is_empty()
}
#[inline] #[inline]
pub fn capacity(&self) -> usize { pub fn capacity(&self) -> usize {
self.uniform_vec.capacity() self.uniform_vec.capacity()

View File

@ -57,8 +57,10 @@ impl Image {
data.len(), data.len(),
"Pixel data, size and format have to match", "Pixel data, size and format have to match",
); );
let mut image = Self::default(); let mut image = Self {
image.data = data; data,
..Default::default()
};
image.texture_descriptor.dimension = dimension; image.texture_descriptor.dimension = dimension;
image.texture_descriptor.size = size; image.texture_descriptor.size = size;
image.texture_descriptor.format = format; image.texture_descriptor.format = format;

View File

@ -212,7 +212,7 @@ pub fn prepare_sprites(
extracted_sprites: Res<ExtractedSprites>, extracted_sprites: Res<ExtractedSprites>,
) { ) {
// dont create buffers when there are no sprites // dont create buffers when there are no sprites
if extracted_sprites.sprites.len() == 0 { if extracted_sprites.sprites.is_empty() {
return; return;
} }
@ -277,6 +277,7 @@ pub fn prepare_sprites(
sprite_meta.indices.write_to_staging_buffer(&render_device); sprite_meta.indices.write_to_staging_buffer(&render_device);
} }
#[allow(clippy::too_many_arguments)]
pub fn queue_sprites( pub fn queue_sprites(
draw_functions: Res<DrawFunctions>, draw_functions: Res<DrawFunctions>,
render_device: Res<RenderDevice>, render_device: Res<RenderDevice>,
@ -287,7 +288,7 @@ pub fn queue_sprites(
gpu_images: Res<RenderAssets<Image>>, gpu_images: Res<RenderAssets<Image>>,
mut views: Query<&mut RenderPhase<Transparent2dPhase>>, mut views: Query<&mut RenderPhase<Transparent2dPhase>>,
) { ) {
if view_meta.uniforms.len() == 0 { if view_meta.uniforms.is_empty() {
return; return;
} }