From 0c6fd70834c19fd9f1525a23c7900658138e9e41 Mon Sep 17 00:00:00 2001 From: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:33:28 -0500 Subject: [PATCH] bevy_core_pipeline: Apply `#![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)]` (#17137) # Objective - https://github.com/bevyengine/bevy/issues/17111 ## Solution Set the `clippy::allow_attributes` and `clippy::allow_attributes_without_reason` lints to `warn`, and bring `bevy_core_pipeline` in line with the new restrictions. ## Testing `cargo clippy` and `cargo test --package bevy_core_pipeline` were run, and no warnings were encountered. --- .../src/auto_exposure/compensation_curve.rs | 5 ++++- crates/bevy_core_pipeline/src/lib.rs | 5 +++++ crates/bevy_core_pipeline/src/tonemapping/mod.rs | 7 +++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs b/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs index 25ec27cee4df2..7a89de331c19c 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs @@ -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`." + )] 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); diff --git a/crates/bevy_core_pipeline/src/lib.rs b/crates/bevy_core_pipeline/src/lib.rs index 6c2ee5bec489b..b47f5513438ae 100644 --- a/crates/bevy_core_pipeline/src/lib.rs +++ b/crates/bevy_core_pipeline/src/lib.rs @@ -1,5 +1,10 @@ #![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")] #![forbid(unsafe_code)] +#![warn( + 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", diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index bfc89cc64568d..e932639b7f420 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -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()),