diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 577ac82c6b..d53ba3d104 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -147,7 +147,10 @@ pub struct NodeQuery { /// The system that sets Interaction for all UI elements based on the mouse cursor activity /// /// Entities with a hidden [`ViewVisibility`] are always treated as released. -#[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 ui_focus_system( mut state: Local, camera_query: Query<(Entity, &Camera)>, diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 1646023d11..4c213541c2 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -96,7 +96,10 @@ struct CameraLayoutInfo { } /// Updates the UI's layout tree, computes the new layout geometry and then updates the sizes and transforms of all the UI nodes. -#[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 ui_layout_system( mut commands: Commands, mut buffers: Local, diff --git a/crates/bevy_ui/src/layout/ui_surface.rs b/crates/bevy_ui/src/layout/ui_surface.rs index 149623b818..b57d1041a3 100644 --- a/crates/bevy_ui/src/layout/ui_surface.rs +++ b/crates/bevy_ui/src/layout/ui_surface.rs @@ -463,7 +463,10 @@ mod tests { ); } - #[allow(unreachable_code)] + #[expect( + unreachable_code, + reason = "Certain pieces of code tested here cause the test to fail if made reachable; see #16362 for progress on fixing this" + )] #[test] fn test_remove_camera_entities() { let mut ui_surface = UiSurface::default(); @@ -512,7 +515,10 @@ mod tests { assert_eq!(root_node_pair, None); } - #[allow(unreachable_code)] + #[expect( + unreachable_code, + reason = "Certain pieces of code tested here cause the test to fail if made reachable; see #16362 for progress on fixing this" + )] #[test] fn test_remove_entities() { let mut ui_surface = UiSurface::default(); @@ -592,7 +598,10 @@ mod tests { assert_eq!(ui_surface.taffy.parent(child_node), Some(parent_node)); } - #[allow(unreachable_code)] + #[expect( + unreachable_code, + reason = "Certain pieces of code tested here cause the test to fail if made reachable; see #16362 for progress on fixing this" + )] #[test] fn test_set_camera_children() { let mut ui_surface = UiSurface::default(); diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index d60e7f4feb..49ca8ab54f 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/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(docsrs, feature(doc_auto_cfg))] #![doc( html_logo_url = "https://bevyengine.org/assets/icon.png", diff --git a/crates/bevy_ui/src/picking_backend.rs b/crates/bevy_ui/src/picking_backend.rs index f1a7cdd4c8..6a7d931531 100644 --- a/crates/bevy_ui/src/picking_backend.rs +++ b/crates/bevy_ui/src/picking_backend.rs @@ -19,8 +19,6 @@ //! camera. //! - To correctly sort picks, the order of `bevy_ui` is set to be the camera order plus 0.5. -#![allow(clippy::type_complexity)] -#![allow(clippy::too_many_arguments)] #![deny(missing_docs)] use crate::{focus::pick_rounded_rect, prelude::*, UiStack}; diff --git a/crates/bevy_ui/src/render/box_shadow.rs b/crates/bevy_ui/src/render/box_shadow.rs index 515e061015..f0b2e18711 100644 --- a/crates/bevy_ui/src/render/box_shadow.rs +++ b/crates/bevy_ui/src/render/box_shadow.rs @@ -380,7 +380,10 @@ pub fn queue_shadows( } } -#[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_shadows( mut commands: Commands, render_device: Res, diff --git a/crates/bevy_ui/src/render/debug_overlay.rs b/crates/bevy_ui/src/render/debug_overlay.rs index 662d0d8d0e..328d8042b7 100644 --- a/crates/bevy_ui/src/render/debug_overlay.rs +++ b/crates/bevy_ui/src/render/debug_overlay.rs @@ -54,7 +54,6 @@ impl Default for UiDebugOptions { } } -#[allow(clippy::too_many_arguments)] pub fn extract_debug_overlay( mut commands: Commands, debug_options: Extract>, diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index c1cf9640d7..d8af8300a9 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -248,7 +248,6 @@ impl ExtractedUiNodes { } } -#[allow(clippy::too_many_arguments)] pub fn extract_uinode_background_colors( mut commands: Commands, mut extracted_uinodes: ResMut, @@ -310,7 +309,6 @@ pub fn extract_uinode_background_colors( } } -#[allow(clippy::too_many_arguments)] pub fn extract_uinode_images( mut commands: Commands, mut extracted_uinodes: ResMut, @@ -613,7 +611,6 @@ pub fn extract_ui_camera_view( transparent_render_phases.retain(|entity, _| live_entities.contains(entity)); } -#[allow(clippy::too_many_arguments)] pub fn extract_text_sections( mut commands: Commands, mut extracted_uinodes: ResMut, @@ -790,7 +787,6 @@ pub mod shader_flags { pub const BORDER: u32 = 8; } -#[allow(clippy::too_many_arguments)] pub fn queue_uinodes( extracted_uinodes: Res, ui_pipeline: Res, @@ -839,7 +835,10 @@ pub struct ImageNodeBindGroups { pub values: HashMap, BindGroup>, } -#[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_uinodes( mut commands: Commands, render_device: Res, diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 831cc71cd4..3176e06ed6 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -424,7 +424,10 @@ pub fn extract_ui_material_nodes( } } -#[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_uimaterial_nodes( mut commands: Commands, render_device: Res, @@ -605,7 +608,10 @@ impl RenderAsset for PreparedUiMaterial { } } -#[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 queue_ui_material_nodes( extracted_uinodes: Res>, draw_functions: Res>, diff --git a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs index 9bee1ea8df..aa1a51b611 100644 --- a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs @@ -377,7 +377,10 @@ pub fn queue_ui_slices( } } -#[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_ui_slices( mut commands: Commands, render_device: Res, diff --git a/crates/bevy_ui/src/stack.rs b/crates/bevy_ui/src/stack.rs index a8283e0938..40512edf88 100644 --- a/crates/bevy_ui/src/stack.rs +++ b/crates/bevy_ui/src/stack.rs @@ -38,7 +38,10 @@ impl ChildBufferCache { /// Create a list of root nodes from parentless entities and entities with a `GlobalZIndex` component. /// Then build the `UiStack` from a walk of the existing layout trees starting from each root node, /// filtering branches by `Without`so that we don't revisit nodes. -#[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 ui_stack_system( mut cache: Local, mut root_nodes: Local>, diff --git a/crates/bevy_ui/src/ui_material.rs b/crates/bevy_ui/src/ui_material.rs index c6e70a69cd..a9d712d5be 100644 --- a/crates/bevy_ui/src/ui_material.rs +++ b/crates/bevy_ui/src/ui_material.rs @@ -113,7 +113,10 @@ pub trait UiMaterial: AsBindGroup + Asset + Clone + Sized { ShaderRef::Default } - #[allow(unused_variables)] + #[expect( + unused_variables, + reason = "The parameters here are intentionally unused by the default implementation; however, putting underscores here will result in the underscores being copied by rust-analyzer's tab completion." + )] #[inline] fn specialize(descriptor: &mut RenderPipelineDescriptor, key: UiMaterialKey) {} } diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 47a4e2cf7a..f08f17a19b 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -1812,11 +1812,9 @@ pub struct GridPlacement { } impl GridPlacement { - #[allow(unsafe_code)] pub const DEFAULT: Self = Self { start: None, - // SAFETY: This is trivially safe as 1 is non-zero. - span: Some(unsafe { NonZero::::new_unchecked(1) }), + span: NonZero::::new(1), end: None, }; diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 9274ff87ea..d608c7cd6d 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -188,7 +188,10 @@ impl Measure for TextMeasure { } } -#[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." +)] #[inline] fn create_text_measure<'a>( entity: Entity, @@ -242,7 +245,10 @@ fn create_text_measure<'a>( /// is only able to detect that a `Text` component has changed and will regenerate the `Measure` on /// color changes. This can be expensive, particularly for large blocks of text, and the [`bypass_change_detection`](bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection) /// method should be called when only changing the `Text`'s colors. -#[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 measure_text_system( mut scale_factors_buffer: Local>, mut last_scale_factors: Local>, @@ -310,7 +316,10 @@ pub fn measure_text_system( core::mem::swap(&mut *last_scale_factors, &mut *scale_factors_buffer); } -#[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." +)] #[inline] fn queue_text( entity: Entity, @@ -382,7 +391,10 @@ fn queue_text( /// /// [`ResMut>`](Assets) -- This system only adds new [`Image`] assets. /// It does not modify or observe existing ones. The exception is when adding new glyphs to a [`bevy_text::FontAtlas`]. -#[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 text_system( mut textures: ResMut>, fonts: Res>,