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

bevy_core_pipeline: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] #17137

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ impl AutoExposureCompensationCurve {
let lut_inv_range = 1.0 / (lut_end - lut_begin);

// Iterate over all LUT entries whose pixel centers fall within the current segment.
#[allow(clippy::needless_range_loop)]
#[expect(
clippy::needless_range_loop,
reason = "This for-loop also uses `i` to calculate a value `t`."
)]
Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to mention: I actually spent some time seeing if I could rewrite this loop to use an iterator (as the lint suggests to do).

However, I ultimately opted not to do so, as I found that I couldn't easily get i to be the same values without some very awkward-looking code.

I don't believe it's impossible to make an iterator work here though.

Copy link
Contributor

@Bleachfuel Bleachfuel Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

let iter  = lut_begin.ceil() as usize..=lut_end.floor() as usize

for i in iter {
}

seems a bit unnessecary tbh.

Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, that would silence the lint - but I suspect that that's a false negative with clippy. Hence, I don't think it would be a good idea compared to just silencing the lint as I have.

for i in lut_begin.ceil() as usize..=lut_end.floor() as usize {
let t = (i as f32 - lut_begin) * lut_inv_range;
lut[i] = previous.y.lerp(current.y, t);
Expand Down
20 changes: 16 additions & 4 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,10 @@ pub fn extract_core_3d_camera_phases(

// Extract the render phases for the prepass

#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
pub fn extract_camera_prepass_phase(
mut commands: Commands,
mut opaque_3d_prepass_phases: ResMut<ViewBinnedRenderPhases<Opaque3dPrepass>>,
Expand Down Expand Up @@ -689,7 +692,10 @@ pub fn extract_camera_prepass_phase(
alpha_mask_3d_deferred_phases.retain(|entity, _| live_entities.contains(entity));
}

#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
pub fn prepare_core_3d_depth_textures(
mut commands: Commands,
mut texture_cache: ResMut<TextureCache>,
Expand Down Expand Up @@ -780,7 +786,10 @@ pub struct ViewTransmissionTexture {
pub sampler: Sampler,
}

#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
pub fn prepare_core_3d_transmission_textures(
mut commands: Commands,
mut texture_cache: ResMut<TextureCache>,
Expand Down Expand Up @@ -880,7 +889,10 @@ pub fn check_msaa(mut deferred_views: Query<&mut Msaa, (With<Camera>, With<Defer
}

// Prepares the textures used by the prepass
#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
pub fn prepare_prepass_textures(
mut commands: Commands,
mut texture_cache: ResMut<TextureCache>,
Expand Down
5 changes: 5 additions & 0 deletions crates/bevy_core_pipeline/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![forbid(unsafe_code)]
#![deny(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_core_pipeline/src/oit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ pub struct OrderIndependentTransparencySettingsOffset {
/// This creates or resizes the oit buffers for each camera.
/// It will always create one big buffer that's as big as the biggest buffer needed.
/// Cameras with smaller viewports or less layers will simply use the big buffer and ignore the rest.
#[allow(clippy::type_complexity)]
pub fn prepare_oit_buffers(
mut commands: Commands,
render_device: Res<RenderDevice>,
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_core_pipeline/src/oit/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub struct OitResolvePipelineKey {
layer_count: i32,
}

#[allow(clippy::too_many_arguments)]
pub fn queue_oit_resolve_pipeline(
mut commands: Commands,
pipeline_cache: Res<PipelineCache>,
Expand Down
15 changes: 12 additions & 3 deletions crates/bevy_core_pipeline/src/smaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,10 @@ impl ViewNode for SmaaNode {
/// writes to the two-channel RG edges texture. Additionally, it ensures that
/// all pixels it didn't touch are stenciled out so that phase 2 won't have to
/// examine them.
#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
fn perform_edge_detection(
render_context: &mut RenderContext,
smaa_pipelines: &SmaaPipelines,
Expand Down Expand Up @@ -965,7 +968,10 @@ fn perform_edge_detection(
/// This runs as part of the [`SmaaNode`]. It reads the edges texture and writes
/// to the blend weight texture, using the stencil buffer to avoid processing
/// pixels it doesn't need to examine.
#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
fn perform_blending_weight_calculation(
render_context: &mut RenderContext,
smaa_pipelines: &SmaaPipelines,
Expand Down Expand Up @@ -1024,7 +1030,10 @@ fn perform_blending_weight_calculation(
///
/// This runs as part of the [`SmaaNode`]. It reads from the blend weight
/// texture. It's the only phase that writes to the postprocessing destination.
#[allow(clippy::too_many_arguments)]
#[expect(
clippy::too_many_arguments,
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
)]
fn perform_neighborhood_blending(
render_context: &mut RenderContext,
smaa_pipelines: &SmaaPipelines,
Expand Down
7 changes: 5 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,11 @@ pub fn get_lut_bind_group_layout_entries() -> [BindGroupLayoutEntryBuilder; 2] {
]
}

// allow(dead_code) so it doesn't complain when the tonemapping_luts feature is disabled
#[allow(dead_code)]
#[expect(clippy::allow_attributes, reason = "`dead_code` is not always linted.")]
#[allow(
dead_code,
reason = "There is unused code when the `tonemapping_luts` feature is disabled."
)]
fn setup_tonemapping_lut_image(bytes: &[u8], image_type: ImageType) -> Image {
let image_sampler = ImageSampler::Descriptor(bevy_image::ImageSamplerDescriptor {
label: Some("Tonemapping LUT sampler".to_string()),
Expand Down
Loading