Skip to content

Commit 3d797d7

Browse files
authored
bevy_sprite: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (Attempt 2) (#17184)
I broke the commit history on the other one, #17160. Woops. # Objective - #17111 ## Solution Set the `clippy::allow_attributes` and `clippy::allow_attributes_without_reason` lints to `deny`, and bring `bevy_sprite` in line with the new restrictions. ## Testing `cargo clippy` and `cargo test --package bevy_sprite` were run, and no errors were encountered.
1 parent b386d08 commit 3d797d7

File tree

6 files changed

+45
-8
lines changed

6 files changed

+45
-8
lines changed

crates/bevy_sprite/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
22
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
33
#![forbid(unsafe_code)]
4+
#![deny(
5+
clippy::allow_attributes,
6+
clippy::allow_attributes_without_reason,
7+
reason = "See #17111; To be removed once all crates are in-line with these attributes"
8+
)]
49
#![doc(
510
html_logo_url = "https://bevyengine.org/assets/icon.png",
611
html_favicon_url = "https://bevyengine.org/assets/icon.png"
@@ -64,6 +69,14 @@ pub struct SpritePlugin {
6469
pub add_picking: bool,
6570
}
6671

72+
#[expect(
73+
clippy::allow_attributes,
74+
reason = "clippy::derivable_impls is not always linted"
75+
)]
76+
#[allow(
77+
clippy::derivable_impls,
78+
reason = "Known false positive with clippy: <https://github.com/rust-lang/rust-clippy/issues/13160>"
79+
)]
6780
impl Default for SpritePlugin {
6881
fn default() -> Self {
6982
Self {

crates/bevy_sprite/src/mesh2d/material.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ pub trait Material2d: AsBindGroup + Asset + Clone + Sized {
135135
}
136136

137137
/// Customizes the default [`RenderPipelineDescriptor`].
138-
#[allow(unused_variables)]
138+
#[expect(
139+
unused_variables,
140+
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."
141+
)]
139142
#[inline]
140143
fn specialize(
141144
descriptor: &mut RenderPipelineDescriptor,
@@ -464,7 +467,10 @@ pub const fn tonemapping_pipeline_key(tonemapping: Tonemapping) -> Mesh2dPipelin
464467
}
465468
}
466469

467-
#[allow(clippy::too_many_arguments)]
470+
#[expect(
471+
clippy::too_many_arguments,
472+
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
473+
)]
468474
pub fn queue_material2d_meshes<M: Material2d>(
469475
opaque_draw_functions: Res<DrawFunctions<Opaque2d>>,
470476
alpha_mask_draw_functions: Res<DrawFunctions<AlphaMask2d>>,

crates/bevy_sprite/src/mesh2d/mesh.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,10 @@ pub struct Mesh2dViewBindGroup {
717717
pub value: BindGroup,
718718
}
719719

720-
#[allow(clippy::too_many_arguments)]
720+
#[expect(
721+
clippy::too_many_arguments,
722+
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
723+
)]
721724
pub fn prepare_mesh2d_view_bind_groups(
722725
mut commands: Commands,
723726
render_device: Res<RenderDevice>,

crates/bevy_sprite/src/mesh2d/wireframe2d.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ fn global_color_changed(
124124
}
125125

126126
/// Updates the wireframe material when the color in [`Wireframe2dColor`] changes
127-
#[allow(clippy::type_complexity)]
127+
#[expect(
128+
clippy::type_complexity,
129+
reason = "Can't be rewritten with less complex arguments."
130+
)]
128131
fn wireframe_color_changed(
129132
mut materials: ResMut<Assets<Wireframe2dMaterial>>,
130133
mut colors_changed: Query<

crates/bevy_sprite/src/picking_backend.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ impl Plugin for SpritePickingPlugin {
5454
}
5555
}
5656

57-
#[allow(clippy::too_many_arguments)]
57+
#[expect(
58+
clippy::too_many_arguments,
59+
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
60+
)]
5861
fn sprite_picking(
5962
pointers: Query<(&PointerId, &PointerLocation)>,
6063
cameras: Query<(Entity, &Camera, &GlobalTransform, &Projection)>,

crates/bevy_sprite/src/render/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,10 @@ pub struct ImageBindGroups {
494494
values: HashMap<AssetId<Image>, BindGroup>,
495495
}
496496

497-
#[allow(clippy::too_many_arguments)]
497+
#[expect(
498+
clippy::too_many_arguments,
499+
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
500+
)]
498501
pub fn queue_sprites(
499502
mut view_entities: Local<FixedBitSet>,
500503
draw_functions: Res<DrawFunctions<Transparent2d>>,
@@ -582,7 +585,10 @@ pub fn queue_sprites(
582585
}
583586
}
584587

585-
#[allow(clippy::too_many_arguments)]
588+
#[expect(
589+
clippy::too_many_arguments,
590+
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
591+
)]
586592
pub fn prepare_sprite_view_bind_groups(
587593
mut commands: Commands,
588594
render_device: Res<RenderDevice>,
@@ -616,7 +622,10 @@ pub fn prepare_sprite_view_bind_groups(
616622
}
617623
}
618624

619-
#[allow(clippy::too_many_arguments)]
625+
#[expect(
626+
clippy::too_many_arguments,
627+
reason = "Could be rewritten with less arguments using a QueryData-implementing struct, but doesn't need to be."
628+
)]
620629
pub fn prepare_sprite_image_bind_groups(
621630
mut commands: Commands,
622631
mut previous_len: Local<usize>,

0 commit comments

Comments
 (0)