diff --git a/crates/bevy_reflect/src/attributes.rs b/crates/bevy_reflect/src/attributes.rs index 0e751fa57a258..de1313538574b 100644 --- a/crates/bevy_reflect/src/attributes.rs +++ b/crates/bevy_reflect/src/attributes.rs @@ -152,7 +152,6 @@ macro_rules! impl_custom_attribute_methods { $self.custom_attributes().get::() } - #[allow(rustdoc::redundant_explicit_links)] /// Gets a custom attribute by its [`TypeId`](core::any::TypeId). /// /// This is the dynamic equivalent of [`get_attribute`](Self::get_attribute). diff --git a/crates/bevy_reflect/src/from_reflect.rs b/crates/bevy_reflect/src/from_reflect.rs index 71a0dd571591c..dc113d869f3c7 100644 --- a/crates/bevy_reflect/src/from_reflect.rs +++ b/crates/bevy_reflect/src/from_reflect.rs @@ -112,7 +112,6 @@ impl ReflectFromReflect { /// /// This will convert the object to a concrete type if it wasn't already, and return /// the value as `Box`. - #[allow(clippy::wrong_self_convention)] pub fn from_reflect(&self, reflect_value: &dyn PartialReflect) -> Option> { (self.from_reflect)(reflect_value) } diff --git a/crates/bevy_reflect/src/func/info.rs b/crates/bevy_reflect/src/func/info.rs index 797b97e7e1bac..d9c487c4e010c 100644 --- a/crates/bevy_reflect/src/func/info.rs +++ b/crates/bevy_reflect/src/func/info.rs @@ -615,7 +615,6 @@ macro_rules! impl_typed_function { FunctionInfo::new( create_info::() .with_args({ - #[allow(unused_mut)] let mut _index = 0; vec![ $(ArgInfo::new::<$Arg>({ @@ -641,7 +640,6 @@ macro_rules! impl_typed_function { FunctionInfo::new( create_info::() .with_args({ - #[allow(unused_mut)] let mut _index = 1; vec![ ArgInfo::new::<&Receiver>(0), @@ -668,7 +666,6 @@ macro_rules! impl_typed_function { FunctionInfo::new( create_info::() .with_args({ - #[allow(unused_mut)] let mut _index = 1; vec![ ArgInfo::new::<&mut Receiver>(0), @@ -695,7 +692,6 @@ macro_rules! impl_typed_function { FunctionInfo::new( create_info::() .with_args({ - #[allow(unused_mut)] let mut _index = 1; vec![ ArgInfo::new::<&mut Receiver>(0), diff --git a/crates/bevy_reflect/src/func/reflect_fn.rs b/crates/bevy_reflect/src/func/reflect_fn.rs index 38a18141fcf43..b84a58e5c7de1 100644 --- a/crates/bevy_reflect/src/func/reflect_fn.rs +++ b/crates/bevy_reflect/src/func/reflect_fn.rs @@ -91,7 +91,14 @@ macro_rules! impl_reflect_fn { // This clause essentially asserts that `Arg::This` is the same type as `Arg` Function: for<'a> Fn($($Arg::This<'a>),*) -> ReturnType + 'env, { - #[allow(unused_mut)] + #[expect( + clippy::allow_attributes, + reason = "This lint is part of a macro, which may not always trigger the `unused_mut` lint." + )] + #[allow( + unused_mut, + reason = "Some invocations of this macro may trigger the `unused_mut` lint, where others won't." + )] fn reflect_call<'a>(&self, mut args: ArgList<'a>) -> FunctionResult<'a> { const COUNT: usize = count_tokens!($($Arg)*); diff --git a/crates/bevy_reflect/src/func/reflect_fn_mut.rs b/crates/bevy_reflect/src/func/reflect_fn_mut.rs index 760e657037c5b..025725fbead86 100644 --- a/crates/bevy_reflect/src/func/reflect_fn_mut.rs +++ b/crates/bevy_reflect/src/func/reflect_fn_mut.rs @@ -98,7 +98,14 @@ macro_rules! impl_reflect_fn_mut { // This clause essentially asserts that `Arg::This` is the same type as `Arg` Function: for<'a> FnMut($($Arg::This<'a>),*) -> ReturnType + 'env, { - #[allow(unused_mut)] + #[expect( + clippy::allow_attributes, + reason = "This lint is part of a macro, which may not always trigger the `unused_mut` lint." + )] + #[allow( + unused_mut, + reason = "Some invocations of this macro may trigger the `unused_mut` lint, where others won't." + )] fn reflect_call_mut<'a>(&mut self, mut args: ArgList<'a>) -> FunctionResult<'a> { const COUNT: usize = count_tokens!($($Arg)*); diff --git a/crates/bevy_reflect/src/impls/glam.rs b/crates/bevy_reflect/src/impls/glam.rs index cd7551cf740e9..943553ef572b8 100644 --- a/crates/bevy_reflect/src/impls/glam.rs +++ b/crates/bevy_reflect/src/impls/glam.rs @@ -10,7 +10,10 @@ macro_rules! reflect_enum { impl_reflect!($(#[$meta])* enum $ident { $($ty)* }); #[assert_type_match($ident, test_only)] - #[allow(clippy::upper_case_acronyms)] + #[expect( + clippy::upper_case_acronyms, + reason = "The variants used are not acronyms." + )] enum $ident { $($ty)* } }; } diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index c5e8cc3a254f2..c8b0f39754b99 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -1,5 +1,7 @@ -// Temporary workaround for impl_reflect!(Option/Result false-positive -#![allow(unused_qualifications)] +#![expect( + unused_qualifications, + reason = "Temporary workaround for impl_reflect!(Option/Result false-positive" +)] use crate::{ self as bevy_reflect, impl_type_path, map_apply, map_partial_eq, map_try_apply, @@ -236,7 +238,6 @@ macro_rules! impl_reflect_for_atomic { #[cfg(feature = "functions")] crate::func::macros::impl_function_traits!($ty); - #[allow(unused_mut)] impl GetTypeRegistration for $ty where $ty: Any + Send + Sync, diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index c6e5ba0b4515d..3f8ec04ae1ca0 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -1,4 +1,9 @@ #![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")] +#![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( any(docsrs, docsrs_dep), expect( @@ -683,8 +688,7 @@ pub mod __macro_exports { note = "consider annotating `{Self}` with `#[derive(Reflect)]`" )] pub trait RegisterForReflection { - #[allow(unused_variables)] - fn __register(registry: &mut TypeRegistry) {} + fn __register(_registry: &mut TypeRegistry) {} } impl RegisterForReflection for T { @@ -709,7 +713,10 @@ pub mod __macro_exports { } #[cfg(test)] -#[allow(clippy::disallowed_types, clippy::approx_constant)] +#[expect( + clippy::approx_constant, + reason = "We don't need the exact value of Pi here." +)] mod tests { use ::serde::{de::DeserializeSeed, Deserialize, Serialize}; use alloc::borrow::Cow; @@ -866,7 +873,6 @@ mod tests { } #[test] - #[allow(clippy::disallowed_types)] fn reflect_unit_struct() { #[derive(Reflect)] struct Foo(u32, u64); @@ -2138,7 +2144,7 @@ mod tests { enum_struct: SomeEnum, custom: CustomDebug, #[reflect(ignore)] - #[allow(dead_code)] + #[expect(dead_code, reason = "This value is intended to not be reflected.")] ignored: isize, } diff --git a/crates/bevy_reflect/src/path/mod.rs b/crates/bevy_reflect/src/path/mod.rs index 3fe0504cf7408..857bd018b03d6 100644 --- a/crates/bevy_reflect/src/path/mod.rs +++ b/crates/bevy_reflect/src/path/mod.rs @@ -502,7 +502,10 @@ impl core::ops::IndexMut for ParsedPath { } #[cfg(test)] -#[allow(clippy::float_cmp, clippy::approx_constant)] +#[expect( + clippy::approx_constant, + reason = "We don't need the exact value of Pi here." +)] mod tests { use super::*; use crate as bevy_reflect; diff --git a/crates/bevy_reflect/src/path/parse.rs b/crates/bevy_reflect/src/path/parse.rs index bc48fe9c01be0..2ab2939a30ae4 100644 --- a/crates/bevy_reflect/src/path/parse.rs +++ b/crates/bevy_reflect/src/path/parse.rs @@ -64,7 +64,10 @@ impl<'a> PathParser<'a> { // the last byte before an ASCII utf-8 character (ie: it is a char // boundary). // - The slice always starts after a symbol ie: an ASCII character's boundary. - #[allow(unsafe_code)] + #[expect( + unsafe_code, + reason = "We have fulfilled the Safety requirements for `from_utf8_unchecked`." + )] let ident = unsafe { from_utf8_unchecked(ident) }; self.remaining = remaining; diff --git a/crates/bevy_reflect/src/serde/mod.rs b/crates/bevy_reflect/src/serde/mod.rs index 3fcaa6aafc7b3..d1e058abe1e3a 100644 --- a/crates/bevy_reflect/src/serde/mod.rs +++ b/crates/bevy_reflect/src/serde/mod.rs @@ -199,7 +199,7 @@ mod tests { #[reflect_trait] trait Enemy: Reflect + Debug { - #[allow(dead_code, reason = "this method is purely for testing purposes")] + #[expect(dead_code, reason = "this method is purely for testing purposes")] fn hp(&self) -> u8; } diff --git a/crates/bevy_reflect/src/type_registry.rs b/crates/bevy_reflect/src/type_registry.rs index 609c66d1856ac..6c97825bccca3 100644 --- a/crates/bevy_reflect/src/type_registry.rs +++ b/crates/bevy_reflect/src/type_registry.rs @@ -79,8 +79,7 @@ pub trait GetTypeRegistration: 'static { /// /// This method is called by [`TypeRegistry::register`] to register any other required types. /// Often, this is done for fields of structs and enum variants to ensure all types are properly registered. - #[allow(unused_variables)] - fn register_type_dependencies(registry: &mut TypeRegistry) {} + fn register_type_dependencies(_registry: &mut TypeRegistry) {} } impl Default for TypeRegistry { @@ -785,7 +784,10 @@ pub struct ReflectFromPtr { from_ptr_mut: unsafe fn(PtrMut) -> &mut dyn Reflect, } -#[allow(unsafe_code)] +#[expect( + unsafe_code, + reason = "We must interact with pointers here, which are inherently unsafe." +)] impl ReflectFromPtr { /// Returns the [`TypeId`] that the [`ReflectFromPtr`] was constructed for. pub fn type_id(&self) -> TypeId { @@ -837,7 +839,10 @@ impl ReflectFromPtr { } } -#[allow(unsafe_code)] +#[expect( + unsafe_code, + reason = "We must interact with pointers here, which are inherently unsafe." +)] impl FromType for ReflectFromPtr { fn from_type() -> Self { ReflectFromPtr { @@ -857,7 +862,10 @@ impl FromType for ReflectFromPtr { } #[cfg(test)] -#[allow(unsafe_code)] +#[expect( + unsafe_code, + reason = "We must interact with pointers here, which are inherently unsafe." +)] mod test { use super::*; use crate as bevy_reflect;