bevy_ui: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17229)
# Objective - https://github.com/bevyengine/bevy/issues/17111 ## Solution Set the `clippy::allow_attributes` and `clippy::allow_attributes_without_reason` lints to `deny`, and bring `bevy_ui` in line with the new restrictions. ## Testing `cargo clippy --tests` and `cargo test --package bevy_ui` were run, and no errors were encountered.
This commit is contained in:
parent
5f0674f6c3
commit
8b4c25ad5f
@ -147,7 +147,10 @@ pub struct NodeQuery {
|
|||||||
/// The system that sets Interaction for all UI elements based on the mouse cursor activity
|
/// 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.
|
/// 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(
|
pub fn ui_focus_system(
|
||||||
mut state: Local<State>,
|
mut state: Local<State>,
|
||||||
camera_query: Query<(Entity, &Camera)>,
|
camera_query: Query<(Entity, &Camera)>,
|
||||||
|
|||||||
@ -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.
|
/// 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(
|
pub fn ui_layout_system(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut buffers: Local<UiLayoutSystemBuffers>,
|
mut buffers: Local<UiLayoutSystemBuffers>,
|
||||||
|
|||||||
@ -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]
|
#[test]
|
||||||
fn test_remove_camera_entities() {
|
fn test_remove_camera_entities() {
|
||||||
let mut ui_surface = UiSurface::default();
|
let mut ui_surface = UiSurface::default();
|
||||||
@ -512,7 +515,10 @@ mod tests {
|
|||||||
assert_eq!(root_node_pair, None);
|
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]
|
#[test]
|
||||||
fn test_remove_entities() {
|
fn test_remove_entities() {
|
||||||
let mut ui_surface = UiSurface::default();
|
let mut ui_surface = UiSurface::default();
|
||||||
@ -592,7 +598,10 @@ mod tests {
|
|||||||
assert_eq!(ui_surface.taffy.parent(child_node), Some(parent_node));
|
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]
|
#[test]
|
||||||
fn test_set_camera_children() {
|
fn test_set_camera_children() {
|
||||||
let mut ui_surface = UiSurface::default();
|
let mut ui_surface = UiSurface::default();
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
|
#![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))]
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||||
#![doc(
|
#![doc(
|
||||||
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
||||||
|
|||||||
@ -19,8 +19,6 @@
|
|||||||
//! camera.
|
//! camera.
|
||||||
//! - To correctly sort picks, the order of `bevy_ui` is set to be the camera order plus 0.5.
|
//! - 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)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use crate::{focus::pick_rounded_rect, prelude::*, UiStack};
|
use crate::{focus::pick_rounded_rect, prelude::*, UiStack};
|
||||||
|
|||||||
@ -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(
|
pub fn prepare_shadows(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
render_device: Res<RenderDevice>,
|
render_device: Res<RenderDevice>,
|
||||||
|
|||||||
@ -54,7 +54,6 @@ impl Default for UiDebugOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn extract_debug_overlay(
|
pub fn extract_debug_overlay(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
debug_options: Extract<Res<UiDebugOptions>>,
|
debug_options: Extract<Res<UiDebugOptions>>,
|
||||||
|
|||||||
@ -248,7 +248,6 @@ impl ExtractedUiNodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn extract_uinode_background_colors(
|
pub fn extract_uinode_background_colors(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut extracted_uinodes: ResMut<ExtractedUiNodes>,
|
mut extracted_uinodes: ResMut<ExtractedUiNodes>,
|
||||||
@ -310,7 +309,6 @@ pub fn extract_uinode_background_colors(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn extract_uinode_images(
|
pub fn extract_uinode_images(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut extracted_uinodes: ResMut<ExtractedUiNodes>,
|
mut extracted_uinodes: ResMut<ExtractedUiNodes>,
|
||||||
@ -613,7 +611,6 @@ pub fn extract_ui_camera_view(
|
|||||||
transparent_render_phases.retain(|entity, _| live_entities.contains(entity));
|
transparent_render_phases.retain(|entity, _| live_entities.contains(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn extract_text_sections(
|
pub fn extract_text_sections(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut extracted_uinodes: ResMut<ExtractedUiNodes>,
|
mut extracted_uinodes: ResMut<ExtractedUiNodes>,
|
||||||
@ -790,7 +787,6 @@ pub mod shader_flags {
|
|||||||
pub const BORDER: u32 = 8;
|
pub const BORDER: u32 = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn queue_uinodes(
|
pub fn queue_uinodes(
|
||||||
extracted_uinodes: Res<ExtractedUiNodes>,
|
extracted_uinodes: Res<ExtractedUiNodes>,
|
||||||
ui_pipeline: Res<UiPipeline>,
|
ui_pipeline: Res<UiPipeline>,
|
||||||
@ -839,7 +835,10 @@ pub struct ImageNodeBindGroups {
|
|||||||
pub values: HashMap<AssetId<Image>, BindGroup>,
|
pub values: HashMap<AssetId<Image>, 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(
|
pub fn prepare_uinodes(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
render_device: Res<RenderDevice>,
|
render_device: Res<RenderDevice>,
|
||||||
|
|||||||
@ -424,7 +424,10 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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<M: UiMaterial>(
|
pub fn prepare_uimaterial_nodes<M: UiMaterial>(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
render_device: Res<RenderDevice>,
|
render_device: Res<RenderDevice>,
|
||||||
@ -605,7 +608,10 @@ impl<M: UiMaterial> RenderAsset for PreparedUiMaterial<M> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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<M: UiMaterial>(
|
pub fn queue_ui_material_nodes<M: UiMaterial>(
|
||||||
extracted_uinodes: Res<ExtractedUiMaterialNodes<M>>,
|
extracted_uinodes: Res<ExtractedUiMaterialNodes<M>>,
|
||||||
draw_functions: Res<DrawFunctions<TransparentUi>>,
|
draw_functions: Res<DrawFunctions<TransparentUi>>,
|
||||||
|
|||||||
@ -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(
|
pub fn prepare_ui_slices(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
render_device: Res<RenderDevice>,
|
render_device: Res<RenderDevice>,
|
||||||
|
|||||||
@ -38,7 +38,10 @@ impl ChildBufferCache {
|
|||||||
/// Create a list of root nodes from parentless entities and entities with a `GlobalZIndex` component.
|
/// 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,
|
/// Then build the `UiStack` from a walk of the existing layout trees starting from each root node,
|
||||||
/// filtering branches by `Without<GlobalZIndex>`so that we don't revisit nodes.
|
/// filtering branches by `Without<GlobalZIndex>`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(
|
pub fn ui_stack_system(
|
||||||
mut cache: Local<ChildBufferCache>,
|
mut cache: Local<ChildBufferCache>,
|
||||||
mut root_nodes: Local<Vec<(Entity, (i32, i32))>>,
|
mut root_nodes: Local<Vec<(Entity, (i32, i32))>>,
|
||||||
|
|||||||
@ -113,7 +113,10 @@ pub trait UiMaterial: AsBindGroup + Asset + Clone + Sized {
|
|||||||
ShaderRef::Default
|
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]
|
#[inline]
|
||||||
fn specialize(descriptor: &mut RenderPipelineDescriptor, key: UiMaterialKey<Self>) {}
|
fn specialize(descriptor: &mut RenderPipelineDescriptor, key: UiMaterialKey<Self>) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1812,11 +1812,9 @@ pub struct GridPlacement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GridPlacement {
|
impl GridPlacement {
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub const DEFAULT: Self = Self {
|
pub const DEFAULT: Self = Self {
|
||||||
start: None,
|
start: None,
|
||||||
// SAFETY: This is trivially safe as 1 is non-zero.
|
span: NonZero::<u16>::new(1),
|
||||||
span: Some(unsafe { NonZero::<u16>::new_unchecked(1) }),
|
|
||||||
end: None,
|
end: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -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]
|
#[inline]
|
||||||
fn create_text_measure<'a>(
|
fn create_text_measure<'a>(
|
||||||
entity: Entity,
|
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
|
/// 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)
|
/// 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.
|
/// 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(
|
pub fn measure_text_system(
|
||||||
mut scale_factors_buffer: Local<EntityHashMap<f32>>,
|
mut scale_factors_buffer: Local<EntityHashMap<f32>>,
|
||||||
mut last_scale_factors: Local<EntityHashMap<f32>>,
|
mut last_scale_factors: Local<EntityHashMap<f32>>,
|
||||||
@ -310,7 +316,10 @@ pub fn measure_text_system(
|
|||||||
core::mem::swap(&mut *last_scale_factors, &mut *scale_factors_buffer);
|
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]
|
#[inline]
|
||||||
fn queue_text(
|
fn queue_text(
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
@ -382,7 +391,10 @@ fn queue_text(
|
|||||||
///
|
///
|
||||||
/// [`ResMut<Assets<Image>>`](Assets<Image>) -- This system only adds new [`Image`] assets.
|
/// [`ResMut<Assets<Image>>`](Assets<Image>) -- 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`].
|
/// 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(
|
pub fn text_system(
|
||||||
mut textures: ResMut<Assets<Image>>,
|
mut textures: ResMut<Assets<Image>>,
|
||||||
fonts: Res<Assets<Font>>,
|
fonts: Res<Assets<Font>>,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user