Skip to content

Commit

Permalink
bevy_sprite: Apply `#![deny(clippy::allow_attributes, clippy::allow_a…
Browse files Browse the repository at this point in the history
…ttributes_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.
  • Loading branch information
LikeLakers2 authored Jan 6, 2025
1 parent b386d08 commit 3d797d7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
13 changes: 13 additions & 0 deletions crates/bevy_sprite/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![deny(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"
Expand Down Expand Up @@ -64,6 +69,14 @@ pub struct SpritePlugin {
pub add_picking: bool,
}

#[expect(
clippy::allow_attributes,
reason = "clippy::derivable_impls is not always linted"
)]
#[allow(
clippy::derivable_impls,
reason = "Known false positive with clippy: <https://github.com/rust-lang/rust-clippy/issues/13160>"
)]
impl Default for SpritePlugin {
fn default() -> Self {
Self {
Expand Down
10 changes: 8 additions & 2 deletions crates/bevy_sprite/src/mesh2d/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ pub trait Material2d: AsBindGroup + Asset + Clone + Sized {
}

/// Customizes the default [`RenderPipelineDescriptor`].
#[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,
Expand Down Expand Up @@ -464,7 +467,10 @@ pub const fn tonemapping_pipeline_key(tonemapping: Tonemapping) -> Mesh2dPipelin
}
}

#[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_material2d_meshes<M: Material2d>(
opaque_draw_functions: Res<DrawFunctions<Opaque2d>>,
alpha_mask_draw_functions: Res<DrawFunctions<AlphaMask2d>>,
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,10 @@ pub struct Mesh2dViewBindGroup {
pub value: 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_mesh2d_view_bind_groups(
mut commands: Commands,
render_device: Res<RenderDevice>,
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_sprite/src/mesh2d/wireframe2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ fn global_color_changed(
}

/// Updates the wireframe material when the color in [`Wireframe2dColor`] changes
#[allow(clippy::type_complexity)]
#[expect(
clippy::type_complexity,
reason = "Can't be rewritten with less complex arguments."
)]
fn wireframe_color_changed(
mut materials: ResMut<Assets<Wireframe2dMaterial>>,
mut colors_changed: Query<
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_sprite/src/picking_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ impl Plugin for SpritePickingPlugin {
}
}

#[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."
)]
fn sprite_picking(
pointers: Query<(&PointerId, &PointerLocation)>,
cameras: Query<(Entity, &Camera, &GlobalTransform, &Projection)>,
Expand Down
15 changes: 12 additions & 3 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ pub struct ImageBindGroups {
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 queue_sprites(
mut view_entities: Local<FixedBitSet>,
draw_functions: Res<DrawFunctions<Transparent2d>>,
Expand Down Expand Up @@ -582,7 +585,10 @@ pub fn queue_sprites(
}
}

#[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_sprite_view_bind_groups(
mut commands: Commands,
render_device: Res<RenderDevice>,
Expand Down Expand Up @@ -616,7 +622,10 @@ pub fn prepare_sprite_view_bind_groups(
}
}

#[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_sprite_image_bind_groups(
mut commands: Commands,
mut previous_len: Local<usize>,
Expand Down

0 comments on commit 3d797d7

Please sign in to comment.