From 5d00ef42371dbb96a5ed6fc29dda02a650cca2c3 Mon Sep 17 00:00:00 2001 From: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:44:34 -0500 Subject: [PATCH] bevy_app: Apply `#[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]` (#17095) # Objective We want to deny the following lints: * `clippy::allow_attributes` - Because there's no reason to `#[allow(...)]` an attribute if it wouldn't lint against anything; you should always use `#[expect(...)]` * `clippy::allow_attributes_without_reason` - Because documenting the reason for allowing/expecting a lint is always good ## Solution Set the `clippy::allow_attributes` and `clippy::allow_attributes_without_reason` lints to `deny`, and bring `bevy_reflect` in line with the new restrictions. No code changes have been made - except if a lint that was previously `allow(...)`'d could be removed via small code changes. For example, `unused_variables` can be handled by adding a `_` to the beginning of a field's name. ## Testing I ran `cargo clippy`, and received no errors. --- crates/bevy_app/src/lib.rs | 1 + crates/bevy_app/src/plugin.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index ff680e4f04..b9e2902961 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -7,6 +7,7 @@ )] #![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))] #![forbid(unsafe_code)] +#![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] #![doc( html_logo_url = "https://bevyengine.org/assets/icon.png", html_favicon_url = "https://bevyengine.org/assets/icon.png" diff --git a/crates/bevy_app/src/plugin.rs b/crates/bevy_app/src/plugin.rs index 724dbfde93..af6238428f 100644 --- a/crates/bevy_app/src/plugin.rs +++ b/crates/bevy_app/src/plugin.rs @@ -183,7 +183,10 @@ mod sealed { where $($plugins: Plugins<$param>),* { - // We use `allow` instead of `expect` here because the lint is not generated for all cases. + #[expect( + clippy::allow_attributes, + reason = "This is inside a macro, and as such, may not trigger in all cases." + )] #[allow(non_snake_case, reason = "`all_tuples!()` generates non-snake-case variable names.")] #[allow(unused_variables, reason = "`app` is unused when implemented for the unit type `()`.")] #[track_caller]