Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary parens #11075

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/bevy_asset/src/io/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ impl AssetSourceBuilder {
watch: bool,
watch_processed: bool,
) -> Option<AssetSource> {
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,
Expand All @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_audio/src/audio_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
});

Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1717,12 +1717,12 @@ mod tests {
let mut sched = Schedule::default();
sched.add_systems(
(
(|mut res: ResMut<C>| {
|mut res: ResMut<C>| {
res.0 += 1;
}),
(|mut res: ResMut<C>| {
},
|mut res: ResMut<C>| {
res.0 += 2;
}),
},
)
.distributive_run_if(resource_exists::<A>().or_else(resource_exists::<B>())),
);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/arcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_gizmos/src/circles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
4 changes: 2 additions & 2 deletions crates/bevy_macro_utils/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn #trait_path> {
::std::boxed::Box::new(::std::clone::Clone::clone(self))
Expand All @@ -95,6 +95,6 @@ pub fn derive_label(
::std::hash::Hash::hash(self, &mut state);
}
}
})
}
.into()
}
42 changes: 21 additions & 21 deletions crates/bevy_pbr/src/pbr_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
40 changes: 20 additions & 20 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_pbr/src/render/mesh_view_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/mesh2d/color_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl From<Handle<Image>> for ColorMaterial {
bitflags::bitflags! {
#[repr(transparent)]
pub struct ColorMaterialFlags: u32 {
const TEXTURE = (1 << 0);
const TEXTURE = 1 << 0;
const NONE = 0;
const UNINITIALIZED = 0xFFFF;
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs/iter_combinations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion examples/stress_tests/bevymark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down