Skip to content

bevy_sprite: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] #17160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 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 All @@ -23,6 +28,10 @@ mod texture_slice;
/// The sprite prelude.
///
/// This includes the most common types in this crate, re-exported for your convenience.
#[expect(
deprecated,
reason = "Items here are part of a prelude meant for consumers of this crate, not for us."
)]
pub mod prelude {
#[doc(hidden)]
pub use crate::{
Expand Down Expand Up @@ -64,6 +73,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
7 changes: 7 additions & 0 deletions crates/bevy_sprite/src/mesh2d/color_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,10 @@ impl Material2d for ColorMaterial {
self.alpha_mode
}
}

/// A component bundle for entities with a [`Mesh2d`](crate::Mesh2d) and a [`ColorMaterial`].
#[deprecated(
since = "0.15.0",
note = "Use the `Mesh3d` and `MeshMaterial3d` components instead. Inserting them will now also insert the other components required by them automatically."
)]
pub type ColorMesh2dBundle = MaterialMesh2dBundle<ColorMaterial>;
48 changes: 46 additions & 2 deletions crates/bevy_sprite/src/mesh2d/material.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#![expect(
deprecated,
reason = "Rustc lints about the use of deprecated items, on the trait impls generated by the derives attached to MaterialMesh2dBundle."
)]

use crate::{
DrawMesh2d, Mesh2d, Mesh2dPipeline, Mesh2dPipelineKey, RenderMesh2dInstances,
SetMesh2dBindGroup, SetMesh2dViewBindGroup,
Expand Down Expand Up @@ -136,7 +141,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 @@ -465,7 +473,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 Expand Up @@ -671,3 +682,36 @@ impl<M: Material2d> RenderAsset for PreparedMaterial2d<M> {
}
}
}

/// A component bundle for entities with a [`Mesh2d`] and a [`MeshMaterial2d`].
#[derive(Bundle, Clone)]
#[deprecated(
since = "0.15.0",
note = "Use the `Mesh2d` and `MeshMaterial2d` components instead. Inserting them will now also insert the other components required by them automatically."
)]
pub struct MaterialMesh2dBundle<M: Material2d> {
pub mesh: Mesh2d,
pub material: MeshMaterial2d<M>,
pub transform: Transform,
pub global_transform: GlobalTransform,
/// User indication of whether an entity is visible
pub visibility: Visibility,
// Inherited visibility of an entity.
pub inherited_visibility: InheritedVisibility,
// Indication of whether an entity is visible in any view.
pub view_visibility: ViewVisibility,
}

impl<M: Material2d> Default for MaterialMesh2dBundle<M> {
fn default() -> Self {
Self {
mesh: Default::default(),
material: Default::default(),
transform: Default::default(),
global_transform: Default::default(),
visibility: Default::default(),
inherited_visibility: Default::default(),
view_visibility: Default::default(),
}
}
}
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
Loading