From 8095aff33ddda4305ea12c02d67578d7a5e05de3 Mon Sep 17 00:00:00 2001 From: Tygyh Date: Sun, 17 Dec 2023 12:44:16 +0100 Subject: [PATCH] Remove unnecessary parens --- crates/bevy_asset/src/io/source.rs | 12 +++--- crates/bevy_asset/src/processor/mod.rs | 8 ++-- crates/bevy_audio/src/audio_output.rs | 4 +- crates/bevy_ecs/src/system/mod.rs | 8 ++-- crates/bevy_gizmos/src/arcs.rs | 2 +- crates/bevy_gizmos/src/circles.rs | 4 +- crates/bevy_macro_utils/src/label.rs | 4 +- crates/bevy_pbr/src/pbr_material.rs | 42 +++++++++---------- crates/bevy_pbr/src/render/light.rs | 6 +-- crates/bevy_pbr/src/render/mesh.rs | 40 +++++++++--------- .../bevy_pbr/src/render/mesh_view_bindings.rs | 10 ++--- crates/bevy_render/src/texture/image.rs | 6 +-- .../bevy_sprite/src/mesh2d/color_material.rs | 2 +- crates/bevy_sprite/src/mesh2d/mesh.rs | 6 +-- crates/bevy_sprite/src/render/mod.rs | 8 ++-- examples/ecs/iter_combinations.rs | 2 +- examples/stress_tests/bevymark.rs | 2 +- 17 files changed, 83 insertions(+), 83 deletions(-) diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index b409579344a32..36e01c561260d 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -141,14 +141,14 @@ impl AssetSourceBuilder { watch: bool, watch_processed: bool, ) -> Option { - let reader = (self.reader.as_mut()?)(); - let writer = self.writer.as_mut().and_then(|w| (w)()); - let processed_writer = self.processed_writer.as_mut().and_then(|w| (w)()); + let reader = self.reader.as_mut()?(); + let writer = self.writer.as_mut().and_then(|w| w()); + let processed_writer = self.processed_writer.as_mut().and_then(|w| w()); let mut source = AssetSource { id: id.clone(), reader, writer, - processed_reader: self.processed_reader.as_mut().map(|r| (r)()), + processed_reader: self.processed_reader.as_mut().map(|r| r()), processed_writer, event_receiver: None, watcher: None, @@ -158,7 +158,7 @@ impl AssetSourceBuilder { if watch { let (sender, receiver) = crossbeam_channel::unbounded(); - match self.watcher.as_mut().and_then(|w| (w)(sender)) { + match self.watcher.as_mut().and_then(|w| w(sender)) { Some(w) => { source.watcher = Some(w); source.event_receiver = Some(receiver); @@ -173,7 +173,7 @@ impl AssetSourceBuilder { if watch_processed { let (sender, receiver) = crossbeam_channel::unbounded(); - match self.processed_watcher.as_mut().and_then(|w| (w)(sender)) { + match self.processed_watcher.as_mut().and_then(|w| w(sender)) { Some(w) => { source.processed_watcher = Some(w); source.processed_event_receiver = Some(receiver); diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index 9033a3b08abfa..4ec650e935632 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -878,11 +878,11 @@ impl AssetProcessor { state_is_valid = false; }; let Ok(source) = self.get_source(path.source()) else { - (unrecoverable_err)(&"AssetSource does not exist"); + unrecoverable_err(&"AssetSource does not exist"); continue; }; let Ok(processed_writer) = source.processed_writer() else { - (unrecoverable_err)(&"AssetSource does not have a processed AssetWriter registered"); + unrecoverable_err(&"AssetSource does not have a processed AssetWriter registered"); continue; }; @@ -891,7 +891,7 @@ impl AssetProcessor { AssetWriterError::Io(err) => { // any error but NotFound means we could be in a bad state if err.kind() != ErrorKind::NotFound { - (unrecoverable_err)(&err); + unrecoverable_err(&err); } } } @@ -901,7 +901,7 @@ impl AssetProcessor { AssetWriterError::Io(err) => { // any error but NotFound means we could be in a bad state if err.kind() != ErrorKind::NotFound { - (unrecoverable_err)(&err); + unrecoverable_err(&err); } } } diff --git a/crates/bevy_audio/src/audio_output.rs b/crates/bevy_audio/src/audio_output.rs index ecbf805bc1c34..b799c1a9f5ceb 100644 --- a/crates/bevy_audio/src/audio_output.rs +++ b/crates/bevy_audio/src/audio_output.rs @@ -77,8 +77,8 @@ impl<'w, 's> EarPositions<'w, 's> { .unwrap_or_else(|| { let settings = SpatialListener::default(); ( - (settings.left_ear_offset * self.scale.0), - (settings.right_ear_offset * self.scale.0), + settings.left_ear_offset * self.scale.0, + settings.right_ear_offset * self.scale.0, ) }); diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index cebadc6f3220b..5cd9f0c233468 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -1717,12 +1717,12 @@ mod tests { let mut sched = Schedule::default(); sched.add_systems( ( - (|mut res: ResMut| { + |mut res: ResMut| { res.0 += 1; - }), - (|mut res: ResMut| { + }, + |mut res: ResMut| { res.0 += 2; - }), + }, ) .distributive_run_if(resource_exists::().or_else(resource_exists::())), ); diff --git a/crates/bevy_gizmos/src/arcs.rs b/crates/bevy_gizmos/src/arcs.rs index e84a0d9c885f3..c44ecd22b9d83 100644 --- a/crates/bevy_gizmos/src/arcs.rs +++ b/crates/bevy_gizmos/src/arcs.rs @@ -88,7 +88,7 @@ impl Drop for Arc2dBuilder<'_, '_> { }; let positions = arc_inner(self.direction_angle, self.arc_angle, self.radius, segments) - .map(|vec2| (vec2 + self.position)); + .map(|vec2| vec2 + self.position); self.gizmos.linestrip_2d(positions, self.color); } } diff --git a/crates/bevy_gizmos/src/circles.rs b/crates/bevy_gizmos/src/circles.rs index 1b4948b198c1c..d24dec62e350e 100644 --- a/crates/bevy_gizmos/src/circles.rs +++ b/crates/bevy_gizmos/src/circles.rs @@ -115,7 +115,7 @@ impl Drop for CircleBuilder<'_, '_> { fn drop(&mut self) { let rotation = Quat::from_rotation_arc(Vec3::Z, self.normal); let positions = circle_inner(self.radius, self.segments) - .map(|vec2| (self.position + rotation * vec2.extend(0.))); + .map(|vec2| self.position + rotation * vec2.extend(0.)); self.gizmos.linestrip(positions, self.color); } } @@ -139,7 +139,7 @@ impl Circle2dBuilder<'_, '_> { impl Drop for Circle2dBuilder<'_, '_> { fn drop(&mut self) { - let positions = circle_inner(self.radius, self.segments).map(|vec2| (vec2 + self.position)); + let positions = circle_inner(self.radius, self.segments).map(|vec2| vec2 + self.position); self.gizmos.linestrip_2d(positions, self.color); } } diff --git a/crates/bevy_macro_utils/src/label.rs b/crates/bevy_macro_utils/src/label.rs index 7facb10d1bb1b..a9fe177cb3cf8 100644 --- a/crates/bevy_macro_utils/src/label.rs +++ b/crates/bevy_macro_utils/src/label.rs @@ -79,7 +79,7 @@ pub fn derive_label( }) .unwrap(), ); - (quote! { + quote! { impl #impl_generics #trait_path for #ident #ty_generics #where_clause { fn dyn_clone(&self) -> ::std::boxed::Box { ::std::boxed::Box::new(::std::clone::Clone::clone(self)) @@ -95,6 +95,6 @@ pub fn derive_label( ::std::hash::Hash::hash(self, &mut state); } } - }) + } .into() } diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 77257bc8daadb..178b8053954ad 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -549,27 +549,27 @@ bitflags::bitflags! { /// This is accessible in the shader in the [`StandardMaterialUniform`] #[repr(transparent)] pub struct StandardMaterialFlags: u32 { - const BASE_COLOR_TEXTURE = (1 << 0); - const EMISSIVE_TEXTURE = (1 << 1); - const METALLIC_ROUGHNESS_TEXTURE = (1 << 2); - const OCCLUSION_TEXTURE = (1 << 3); - const DOUBLE_SIDED = (1 << 4); - const UNLIT = (1 << 5); - const TWO_COMPONENT_NORMAL_MAP = (1 << 6); - const FLIP_NORMAL_MAP_Y = (1 << 7); - const FOG_ENABLED = (1 << 8); - const DEPTH_MAP = (1 << 9); // Used for parallax mapping - const SPECULAR_TRANSMISSION_TEXTURE = (1 << 10); - const THICKNESS_TEXTURE = (1 << 11); - const DIFFUSE_TRANSMISSION_TEXTURE = (1 << 12); - const ATTENUATION_ENABLED = (1 << 13); - const ALPHA_MODE_RESERVED_BITS = (Self::ALPHA_MODE_MASK_BITS << Self::ALPHA_MODE_SHIFT_BITS); // ← Bitmask reserving bits for the `AlphaMode` - const ALPHA_MODE_OPAQUE = (0 << Self::ALPHA_MODE_SHIFT_BITS); // ← Values are just sequential values bitshifted into - const ALPHA_MODE_MASK = (1 << Self::ALPHA_MODE_SHIFT_BITS); // the bitmask, and can range from 0 to 7. - const ALPHA_MODE_BLEND = (2 << Self::ALPHA_MODE_SHIFT_BITS); // - const ALPHA_MODE_PREMULTIPLIED = (3 << Self::ALPHA_MODE_SHIFT_BITS); // - const ALPHA_MODE_ADD = (4 << Self::ALPHA_MODE_SHIFT_BITS); // Right now only values 0–5 are used, which still gives - const ALPHA_MODE_MULTIPLY = (5 << Self::ALPHA_MODE_SHIFT_BITS); // ← us "room" for two more modes without adding more bits + const BASE_COLOR_TEXTURE = 1 << 0; + const EMISSIVE_TEXTURE = 1 << 1; + const METALLIC_ROUGHNESS_TEXTURE = 1 << 2; + const OCCLUSION_TEXTURE = 1 << 3; + const DOUBLE_SIDED = 1 << 4; + const UNLIT = 1 << 5; + const TWO_COMPONENT_NORMAL_MAP = 1 << 6; + const FLIP_NORMAL_MAP_Y = 1 << 7; + const FOG_ENABLED = 1 << 8; + const DEPTH_MAP = 1 << 9; // Used for parallax mapping + const SPECULAR_TRANSMISSION_TEXTURE = 1 << 10; + const THICKNESS_TEXTURE = 1 << 11; + const DIFFUSE_TRANSMISSION_TEXTURE = 1 << 12; + const ATTENUATION_ENABLED = 1 << 13; + const ALPHA_MODE_RESERVED_BITS = Self::ALPHA_MODE_MASK_BITS << Self::ALPHA_MODE_SHIFT_BITS; // ← Bitmask reserving bits for the `AlphaMode` + const ALPHA_MODE_OPAQUE = 0 << Self::ALPHA_MODE_SHIFT_BITS; // ← Values are just sequential values bitshifted into + const ALPHA_MODE_MASK = 1 << Self::ALPHA_MODE_SHIFT_BITS; // the bitmask, and can range from 0 to 7. + const ALPHA_MODE_BLEND = 2 << Self::ALPHA_MODE_SHIFT_BITS; // + const ALPHA_MODE_PREMULTIPLIED = 3 << Self::ALPHA_MODE_SHIFT_BITS; // + const ALPHA_MODE_ADD = 4 << Self::ALPHA_MODE_SHIFT_BITS; // Right now only values 0–5 are used, which still gives + const ALPHA_MODE_MULTIPLY = 5 << Self::ALPHA_MODE_SHIFT_BITS; // ← us "room" for two more modes without adding more bits const NONE = 0; const UNINITIALIZED = 0xFFFF; } diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 60d6541b2952e..9b9b635ab0f83 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -145,8 +145,8 @@ impl GpuPointLights { bitflags::bitflags! { #[repr(transparent)] struct PointLightFlags: u32 { - const SHADOWS_ENABLED = (1 << 0); - const SPOT_LIGHT_Y_NEGATIVE = (1 << 1); + const SHADOWS_ENABLED = 1 << 0; + const SPOT_LIGHT_Y_NEGATIVE = 1 << 1; const NONE = 0; const UNINITIALIZED = 0xFFFF; } @@ -177,7 +177,7 @@ pub struct GpuDirectionalLight { bitflags::bitflags! { #[repr(transparent)] struct DirectionalLightFlags: u32 { - const SHADOWS_ENABLED = (1 << 0); + const SHADOWS_ENABLED = 1 << 0; const NONE = 0; const UNINITIALIZED = 0xFFFF; } diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index b9bb6195ad9c9..a983cbad5e094 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -222,11 +222,11 @@ impl From<&MeshTransforms> for MeshUniform { bitflags::bitflags! { #[repr(transparent)] pub struct MeshFlags: u32 { - const SHADOW_RECEIVER = (1 << 0); - const TRANSMITTED_SHADOW_RECEIVER = (1 << 1); + const SHADOW_RECEIVER = 1 << 0; + const TRANSMITTED_SHADOW_RECEIVER = 1 << 1; // Indicates the sign of the determinant of the 3x3 model matrix. If the sign is positive, // then the flag should be set, else it should not be set. - const SIGN_DETERMINANT_MODEL_3X3 = (1 << 31); + const SIGN_DETERMINANT_MODEL_3X3 = 1 << 31; const NONE = 0; const UNINITIALIZED = 0xFFFF; } @@ -477,25 +477,25 @@ bitflags::bitflags! { /// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA. pub struct MeshPipelineKey: u32 { const NONE = 0; - const HDR = (1 << 0); - const TONEMAP_IN_SHADER = (1 << 1); - const DEBAND_DITHER = (1 << 2); - const DEPTH_PREPASS = (1 << 3); - const NORMAL_PREPASS = (1 << 4); - const DEFERRED_PREPASS = (1 << 5); - const MOTION_VECTOR_PREPASS = (1 << 6); - const MAY_DISCARD = (1 << 7); // Guards shader codepaths that may discard, allowing early depth tests in most cases + const HDR = 1 << 0; + const TONEMAP_IN_SHADER = 1 << 1; + const DEBAND_DITHER = 1 << 2; + const DEPTH_PREPASS = 1 << 3; + const NORMAL_PREPASS = 1 << 4; + const DEFERRED_PREPASS = 1 << 5; + const MOTION_VECTOR_PREPASS = 1 << 6; + const MAY_DISCARD = 1 << 7; // Guards shader codepaths that may discard, allowing early depth tests in most cases // See: https://www.khronos.org/opengl/wiki/Early_Fragment_Test - const ENVIRONMENT_MAP = (1 << 8); - const SCREEN_SPACE_AMBIENT_OCCLUSION = (1 << 9); - const DEPTH_CLAMP_ORTHO = (1 << 10); - const TEMPORAL_JITTER = (1 << 11); - const MORPH_TARGETS = (1 << 12); + const ENVIRONMENT_MAP = 1 << 8; + const SCREEN_SPACE_AMBIENT_OCCLUSION = 1 << 9; + const DEPTH_CLAMP_ORTHO = 1 << 10; + const TEMPORAL_JITTER = 1 << 11; + const MORPH_TARGETS = 1 << 12; const BLEND_RESERVED_BITS = Self::BLEND_MASK_BITS << Self::BLEND_SHIFT_BITS; // ← Bitmask reserving bits for the blend state - const BLEND_OPAQUE = (0 << Self::BLEND_SHIFT_BITS); // ← Values are just sequential within the mask, and can range from 0 to 3 - const BLEND_PREMULTIPLIED_ALPHA = (1 << Self::BLEND_SHIFT_BITS); // - const BLEND_MULTIPLY = (2 << Self::BLEND_SHIFT_BITS); // ← We still have room for one more value without adding more bits - const BLEND_ALPHA = (3 << Self::BLEND_SHIFT_BITS); + const BLEND_OPAQUE = 0 << Self::BLEND_SHIFT_BITS; // ← Values are just sequential within the mask, and can range from 0 to 3 + const BLEND_PREMULTIPLIED_ALPHA = 1 << Self::BLEND_SHIFT_BITS; // + const BLEND_MULTIPLY = 2 << Self::BLEND_SHIFT_BITS; // ← We still have room for one more value without adding more bits + const BLEND_ALPHA = 3 << Self::BLEND_SHIFT_BITS; const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS; const PRIMITIVE_TOPOLOGY_RESERVED_BITS = Self::PRIMITIVE_TOPOLOGY_MASK_BITS << Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS; const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS; diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 61140e4377677..eb020cf4e55e7 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -49,11 +49,11 @@ bitflags::bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct MeshPipelineViewLayoutKey: u32 { - const MULTISAMPLED = (1 << 0); - const DEPTH_PREPASS = (1 << 1); - const NORMAL_PREPASS = (1 << 2); - const MOTION_VECTOR_PREPASS = (1 << 3); - const DEFERRED_PREPASS = (1 << 4); + const MULTISAMPLED = 1 << 0; + const DEPTH_PREPASS = 1 << 1; + const NORMAL_PREPASS = 1 << 2; + const MOTION_VECTOR_PREPASS = 1 << 3; + const DEFERRED_PREPASS = 1 << 4; } } diff --git a/crates/bevy_render/src/texture/image.rs b/crates/bevy_render/src/texture/image.rs index 6e31b5892c760..83a7a6a631817 100644 --- a/crates/bevy_render/src/texture/image.rs +++ b/crates/bevy_render/src/texture/image.rs @@ -859,9 +859,9 @@ bitflags::bitflags! { #[repr(transparent)] pub struct CompressedImageFormats: u32 { const NONE = 0; - const ASTC_LDR = (1 << 0); - const BC = (1 << 1); - const ETC2 = (1 << 2); + const ASTC_LDR = 1 << 0; + const BC = 1 << 1; + const ETC2 = 1 << 2; } } diff --git a/crates/bevy_sprite/src/mesh2d/color_material.rs b/crates/bevy_sprite/src/mesh2d/color_material.rs index 8e5e39b006a00..cbf6baf082317 100644 --- a/crates/bevy_sprite/src/mesh2d/color_material.rs +++ b/crates/bevy_sprite/src/mesh2d/color_material.rs @@ -77,7 +77,7 @@ impl From> for ColorMaterial { bitflags::bitflags! { #[repr(transparent)] pub struct ColorMaterialFlags: u32 { - const TEXTURE = (1 << 0); + const TEXTURE = 1 << 0; const NONE = 0; const UNINITIALIZED = 0xFFFF; } diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 03c856068f0fb..d1a9b41907f04 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -369,9 +369,9 @@ bitflags::bitflags! { // FIXME: make normals optional? pub struct Mesh2dPipelineKey: u32 { const NONE = 0; - const HDR = (1 << 0); - const TONEMAP_IN_SHADER = (1 << 1); - const DEBAND_DITHER = (1 << 2); + const HDR = 1 << 0; + const TONEMAP_IN_SHADER = 1 << 1; + const DEBAND_DITHER = 1 << 2; const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS; const PRIMITIVE_TOPOLOGY_RESERVED_BITS = Self::PRIMITIVE_TOPOLOGY_MASK_BITS << Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS; const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS; diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index eaf44fc4ab349..5f257e3c1a878 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -121,10 +121,10 @@ bitflags::bitflags! { // MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA. pub struct SpritePipelineKey: u32 { const NONE = 0; - const COLORED = (1 << 0); - const HDR = (1 << 1); - const TONEMAP_IN_SHADER = (1 << 2); - const DEBAND_DITHER = (1 << 3); + const COLORED = 1 << 0; + const HDR = 1 << 1; + const TONEMAP_IN_SHADER = 1 << 2; + const DEBAND_DITHER = 1 << 3; const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS; const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS; const TONEMAP_METHOD_NONE = 0 << Self::TONEMAP_METHOD_SHIFT_BITS; diff --git a/examples/ecs/iter_combinations.rs b/examples/ecs/iter_combinations.rs index 363dfc726c768..5f63cd52bfbf0 100644 --- a/examples/ecs/iter_combinations.rs +++ b/examples/ecs/iter_combinations.rs @@ -115,7 +115,7 @@ fn generate_bodies( ), material: materials.add(StandardMaterial { base_color: Color::ORANGE_RED, - emissive: (Color::ORANGE_RED * 2.), + emissive: Color::ORANGE_RED * 2., ..default() }), ..default() diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 1c727b28d5927..90ee8b7896170 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -483,7 +483,7 @@ fn movement_system( fn handle_collision(half_extents: Vec2, translation: &Vec3, velocity: &mut Vec3) { if (velocity.x > 0. && translation.x + HALF_BIRD_SIZE > half_extents.x) - || (velocity.x <= 0. && translation.x - HALF_BIRD_SIZE < -(half_extents.x)) + || (velocity.x <= 0. && translation.x - HALF_BIRD_SIZE < -half_extents.x) { velocity.x = -velocity.x; }