mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
fix clippy
This commit is contained in:
parent
bc769d9641
commit
ac6b27925e
20 changed files with 1315 additions and 1299 deletions
|
@ -1,7 +1,6 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{app::AppExit, AppBuilder};
|
||||
use crate::app::{App, AppExit};
|
||||
use bevy_ecs::system::IntoSystem;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Configuration for automated testing on CI
|
||||
#[derive(Deserialize)]
|
||||
|
@ -23,16 +22,15 @@ fn ci_testing_exit_after(
|
|||
*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 =
|
||||
std::env::var("CI_TESTING_CONFIG").unwrap_or_else(|_| "ci_testing_config.ron".to_string());
|
||||
let config: CiTestingConfig = ron::from_str(
|
||||
&std::fs::read_to_string(filename).expect("error reading CI testing configuration file"),
|
||||
)
|
||||
.expect("error deserializing CI testing configuration file");
|
||||
app_builder
|
||||
.insert_resource(config)
|
||||
app.insert_resource(config)
|
||||
.add_system(ci_testing_exit_after.system());
|
||||
|
||||
app_builder
|
||||
app
|
||||
}
|
||||
|
|
|
@ -428,6 +428,11 @@ impl Entities {
|
|||
|
||||
/// Allocates space for entities previously reserved with `reserve_entity` or
|
||||
/// `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)) {
|
||||
let free_cursor = self.free_cursor.get_mut();
|
||||
let current_free_cursor = *free_cursor;
|
||||
|
|
|
@ -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
|
||||
/// 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 {
|
||||
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
|
||||
unsafe impl HasRawWindowHandle for HasRawWindowHandleWrapper {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
self.0.clone()
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,11 +246,7 @@ impl EmitOptions {
|
|||
|
||||
// For testing purposes, we can optionally generate type layout
|
||||
// information using the type-layout crate.
|
||||
let type_layout_derive = if cfg!(feature = "test_type_layout") {
|
||||
quote!(#[derive(::type_layout::TypeLayout)])
|
||||
} else {
|
||||
quote!()
|
||||
};
|
||||
let type_layout_derive = quote!();
|
||||
|
||||
quote! {
|
||||
#[allow(non_snake_case)]
|
||||
|
|
|
@ -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)
|
||||
[![crevice on crates.io](https://img.shields.io/crates/v/crevice.svg)](https://crates.io/crates/crevice)
|
||||
|
|
|
@ -9,7 +9,7 @@ fn main() {
|
|||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
_asset_server: Res<AssetServer>,
|
||||
// mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
) {
|
||||
// let texture_handle = asset_server.load("branding/icon.png");
|
||||
|
|
|
@ -13,7 +13,7 @@ use bevy::{
|
|||
use rand::Rng;
|
||||
|
||||
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 MAX_VELOCITY: f32 = 750.;
|
||||
const BIRD_SCALE: f32 = 0.15;
|
||||
|
@ -66,8 +66,8 @@ struct BirdTexture(Handle<Image>);
|
|||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
window: Res<WindowDescriptor>,
|
||||
mut counter: ResMut<BevyCounter>,
|
||||
_window: Res<WindowDescriptor>,
|
||||
_counter: ResMut<BevyCounter>,
|
||||
asset_server: Res<AssetServer>,
|
||||
) {
|
||||
// spawn_birds(&mut commands, &window, &mut counter, 10);
|
||||
|
@ -129,7 +129,7 @@ fn setup(
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
fn mouse_handler(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
_asset_server: Res<AssetServer>,
|
||||
time: Res<Time>,
|
||||
mouse_button_input: Res<Input<MouseButton>>,
|
||||
window: Res<WindowDescriptor>,
|
||||
|
|
|
@ -19,7 +19,7 @@ use bevy_render2::{
|
|||
|
||||
pub mod draw_3d_graph {
|
||||
pub mod node {
|
||||
pub const SHADOW_PASS: &'static str = "shadow_pass";
|
||||
pub const SHADOW_PASS: &str = "shadow_pass";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ pub fn extract_lights(
|
|||
intensity: light.intensity,
|
||||
range: light.range,
|
||||
radius: light.radius,
|
||||
transform: transform.clone(),
|
||||
transform: *transform,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +341,8 @@ pub fn prepare_lights(
|
|||
// premultiply color by intensity
|
||||
// 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(),
|
||||
radius: light.radius.into(),
|
||||
position: light.transform.translation.into(),
|
||||
radius: light.radius,
|
||||
position: light.transform.translation,
|
||||
inverse_square_range: 1.0 / (light.range * light.range),
|
||||
near: 0.1,
|
||||
far: light.range,
|
||||
|
@ -360,7 +360,7 @@ pub fn prepare_lights(
|
|||
aspect: TextureAspect::All,
|
||||
base_mip_level: 0,
|
||||
mip_level_count: None,
|
||||
base_array_layer: 0 as u32,
|
||||
base_array_layer: 0,
|
||||
array_layer_count: None,
|
||||
});
|
||||
|
||||
|
@ -412,7 +412,7 @@ impl Node for ShadowPassNode {
|
|||
world: &World,
|
||||
) -> Result<(), NodeRunError> {
|
||||
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() {
|
||||
let (view_light, shadow_phase) = self
|
||||
.view_light_query
|
||||
|
|
|
@ -340,10 +340,10 @@ impl FromWorld for PbrShaders {
|
|||
};
|
||||
PbrShaders {
|
||||
pipeline,
|
||||
shader_module,
|
||||
view_layout,
|
||||
material_layout,
|
||||
mesh_layout,
|
||||
shader_module,
|
||||
dummy_white_gpu_image,
|
||||
}
|
||||
}
|
||||
|
@ -466,6 +466,7 @@ fn image_handle_to_view_sampler<'a>(
|
|||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn queue_meshes(
|
||||
mut commands: Commands,
|
||||
draw_functions: Res<DrawFunctions>,
|
||||
|
@ -488,7 +489,7 @@ pub fn queue_meshes(
|
|||
) {
|
||||
let mesh_meta = mesh_meta.into_inner();
|
||||
|
||||
if view_meta.uniforms.len() == 0 {
|
||||
if view_meta.uniforms.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ fn extract_cameras(
|
|||
},
|
||||
ExtractedView {
|
||||
projection: camera.projection_matrix,
|
||||
transform: transform.clone(),
|
||||
transform: *transform,
|
||||
width: window.physical_width(),
|
||||
height: window.physical_height(),
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -26,31 +26,31 @@ use wgpu::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, Texture
|
|||
// 3. "sub graph" modules should be nested beneath their parent graph module
|
||||
|
||||
pub mod node {
|
||||
pub const MAIN_PASS_DEPENDENCIES: &'static str = "main_pass_dependencies";
|
||||
pub const MAIN_PASS_DRIVER: &'static str = "main_pass_driver";
|
||||
pub const VIEW: &'static str = "view";
|
||||
pub const MAIN_PASS_DEPENDENCIES: &str = "main_pass_dependencies";
|
||||
pub const MAIN_PASS_DRIVER: &str = "main_pass_driver";
|
||||
pub const VIEW: &str = "view";
|
||||
}
|
||||
|
||||
pub mod draw_2d_graph {
|
||||
pub const NAME: &'static str = "draw_2d";
|
||||
pub const NAME: &str = "draw_2d";
|
||||
pub mod input {
|
||||
pub const VIEW_ENTITY: &'static str = "view_entity";
|
||||
pub const RENDER_TARGET: &'static str = "render_target";
|
||||
pub const VIEW_ENTITY: &str = "view_entity";
|
||||
pub const RENDER_TARGET: &str = "render_target";
|
||||
}
|
||||
pub mod node {
|
||||
pub const MAIN_PASS: &'static str = "main_pass";
|
||||
pub const MAIN_PASS: &str = "main_pass";
|
||||
}
|
||||
}
|
||||
|
||||
pub mod draw_3d_graph {
|
||||
pub const NAME: &'static str = "draw_3d";
|
||||
pub const NAME: &str = "draw_3d";
|
||||
pub mod input {
|
||||
pub const VIEW_ENTITY: &'static str = "view_entity";
|
||||
pub const RENDER_TARGET: &'static str = "render_target";
|
||||
pub const DEPTH: &'static str = "depth";
|
||||
pub const VIEW_ENTITY: &str = "view_entity";
|
||||
pub const RENDER_TARGET: &str = "render_target";
|
||||
pub const DEPTH: &str = "depth";
|
||||
}
|
||||
pub mod node {
|
||||
pub const MAIN_PASS: &'static str = "main_pass";
|
||||
pub const MAIN_PASS: &str = "main_pass";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -493,6 +493,13 @@ impl Indices {
|
|||
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> {
|
||||
U16(std::slice::Iter<'a, u16>),
|
||||
|
|
|
@ -65,7 +65,7 @@ impl<'a> RenderGraphContext<'a> {
|
|||
let label = label.into();
|
||||
match self.get_input(label.clone())? {
|
||||
SlotValue::TextureView(value) => Ok(value),
|
||||
value @ _ => Err(InputSlotError::MismatchedSlotType {
|
||||
value => Err(InputSlotError::MismatchedSlotType {
|
||||
label,
|
||||
actual: value.slot_type(),
|
||||
expected: SlotType::TextureView,
|
||||
|
@ -80,7 +80,7 @@ impl<'a> RenderGraphContext<'a> {
|
|||
let label = label.into();
|
||||
match self.get_input(label.clone())? {
|
||||
SlotValue::Sampler(value) => Ok(value),
|
||||
value @ _ => Err(InputSlotError::MismatchedSlotType {
|
||||
value => Err(InputSlotError::MismatchedSlotType {
|
||||
label,
|
||||
actual: value.slot_type(),
|
||||
expected: SlotType::Sampler,
|
||||
|
@ -92,7 +92,7 @@ impl<'a> RenderGraphContext<'a> {
|
|||
let label = label.into();
|
||||
match self.get_input(label.clone())? {
|
||||
SlotValue::Buffer(value) => Ok(value),
|
||||
value @ _ => Err(InputSlotError::MismatchedSlotType {
|
||||
value => Err(InputSlotError::MismatchedSlotType {
|
||||
label,
|
||||
actual: value.slot_type(),
|
||||
expected: SlotType::Buffer,
|
||||
|
@ -104,7 +104,7 @@ impl<'a> RenderGraphContext<'a> {
|
|||
let label = label.into();
|
||||
match self.get_input(label.clone())? {
|
||||
SlotValue::Entity(value) => Ok(*value),
|
||||
value @ _ => Err(InputSlotError::MismatchedSlotType {
|
||||
value => Err(InputSlotError::MismatchedSlotType {
|
||||
label,
|
||||
actual: value.slot_type(),
|
||||
expected: SlotType::Entity,
|
||||
|
@ -122,7 +122,7 @@ impl<'a> RenderGraphContext<'a> {
|
|||
let slot_index = self
|
||||
.output_info()
|
||||
.get_slot_index(label.clone())
|
||||
.ok_or(OutputSlotError::InvalidSlot(label.clone()))?;
|
||||
.ok_or_else(|| OutputSlotError::InvalidSlot(label.clone()))?;
|
||||
let slot = self
|
||||
.output_info()
|
||||
.get_slot(slot_index)
|
||||
|
@ -147,7 +147,7 @@ impl<'a> RenderGraphContext<'a> {
|
|||
let sub_graph = self
|
||||
.graph
|
||||
.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() {
|
||||
for (i, input_slot) in input_node.input_slots.iter().enumerate() {
|
||||
if let Some(input_value) = inputs.get(i) {
|
||||
|
@ -168,10 +168,8 @@ impl<'a> RenderGraphContext<'a> {
|
|||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if !inputs.is_empty() {
|
||||
return Err(RunSubGraphError::SubGraphHasNoInputs(name));
|
||||
}
|
||||
} else if !inputs.is_empty() {
|
||||
return Err(RunSubGraphError::SubGraphHasNoInputs(name));
|
||||
}
|
||||
|
||||
self.run_sub_graphs.push(RunSubGraph { name, inputs });
|
||||
|
|
|
@ -194,15 +194,12 @@ impl RenderGraph {
|
|||
let output_slot = output_node_state
|
||||
.output_slots
|
||||
.get_slot(output_index)
|
||||
.ok_or_else(|| {
|
||||
RenderGraphError::InvalidOutputNodeSlot(SlotLabel::Index(output_index))
|
||||
})?;
|
||||
let input_slot = input_node_state
|
||||
.input_slots
|
||||
.get_slot(input_index)
|
||||
.ok_or_else(|| {
|
||||
RenderGraphError::InvalidInputNodeSlot(SlotLabel::Index(input_index))
|
||||
})?;
|
||||
.ok_or(RenderGraphError::InvalidOutputNodeSlot(SlotLabel::Index(
|
||||
output_index,
|
||||
)))?;
|
||||
let input_slot = input_node_state.input_slots.get_slot(input_index).ok_or(
|
||||
RenderGraphError::InvalidInputNodeSlot(SlotLabel::Index(input_index)),
|
||||
)?;
|
||||
|
||||
if let Some(Edge::SlotEdge {
|
||||
output_node: current_output_node,
|
||||
|
|
|
@ -49,6 +49,11 @@ impl<T: AsStd140> UniformVec<T> {
|
|||
self.values.len()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.values.is_empty()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.capacity
|
||||
|
@ -155,6 +160,11 @@ impl<T: AsStd140> DynamicUniformVec<T> {
|
|||
self.uniform_vec.len()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.uniform_vec.is_empty()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.uniform_vec.capacity()
|
||||
|
|
|
@ -57,8 +57,10 @@ impl Image {
|
|||
data.len(),
|
||||
"Pixel data, size and format have to match",
|
||||
);
|
||||
let mut image = Self::default();
|
||||
image.data = data;
|
||||
let mut image = Self {
|
||||
data,
|
||||
..Default::default()
|
||||
};
|
||||
image.texture_descriptor.dimension = dimension;
|
||||
image.texture_descriptor.size = size;
|
||||
image.texture_descriptor.format = format;
|
||||
|
|
|
@ -212,7 +212,7 @@ pub fn prepare_sprites(
|
|||
extracted_sprites: Res<ExtractedSprites>,
|
||||
) {
|
||||
// dont create buffers when there are no sprites
|
||||
if extracted_sprites.sprites.len() == 0 {
|
||||
if extracted_sprites.sprites.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -277,6 +277,7 @@ pub fn prepare_sprites(
|
|||
sprite_meta.indices.write_to_staging_buffer(&render_device);
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn queue_sprites(
|
||||
draw_functions: Res<DrawFunctions>,
|
||||
render_device: Res<RenderDevice>,
|
||||
|
@ -287,7 +288,7 @@ pub fn queue_sprites(
|
|||
gpu_images: Res<RenderAssets<Image>>,
|
||||
mut views: Query<&mut RenderPhase<Transparent2dPhase>>,
|
||||
) {
|
||||
if view_meta.uniforms.len() == 0 {
|
||||
if view_meta.uniforms.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue