Skip to content

Commit 1aa7f98

Browse files
LikeLakers2mrchantey
authored andcommitted
bevy_asset: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (bevyengine#17113)
# Objective - bevyengine#17111 ## Solution Set the `clippy::allow_attributes` and `clippy::allow_attributes_without_reason` lints to `deny`, and bring `bevy_asset` in line with the new restrictions. No code changes have been made - except if a lint that was previously `allow(...)`'d could be removed via small code changes. For example, `unused_variables` can be handled by adding a `_` to the beginning of a field's name. ## Testing `cargo clippy` and `cargo test --package bevy_asset --features multi_threaded` were run, and no errors were encountered.
1 parent 8fe1e5f commit 1aa7f98

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

crates/bevy_asset/src/asset_changed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub struct AssetChangedState<A: AsAssetId> {
148148
_asset: PhantomData<fn(A)>,
149149
}
150150

151-
#[allow(unsafe_code)]
151+
#[expect(unsafe_code, reason = "WorldQuery is an unsafe trait.")]
152152
/// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
153153
unsafe impl<A: AsAssetId> WorldQuery for AssetChanged<A> {
154154
type Item<'w> = ();
@@ -264,7 +264,7 @@ unsafe impl<A: AsAssetId> WorldQuery for AssetChanged<A> {
264264
}
265265
}
266266

267-
#[allow(unsafe_code)]
267+
#[expect(unsafe_code, reason = "QueryFilter is an unsafe trait.")]
268268
/// SAFETY: read-only access
269269
unsafe impl<A: AsAssetId> QueryFilter for AssetChanged<A> {
270270
const IS_ARCHETYPAL: bool = false;

crates/bevy_asset/src/handle.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,11 @@ mod tests {
551551
}
552552

553553
/// Typed and Untyped `Handles` should be orderable amongst each other and themselves
554-
#[allow(clippy::cmp_owned)]
555554
#[test]
555+
#[expect(
556+
clippy::cmp_owned,
557+
reason = "This lints on the assertion that a typed handle converted to an untyped handle maintains its ordering compared to an untyped handle. While the conversion would normally be useless, we need to ensure that converted handles maintain their ordering, making the conversion necessary here."
558+
)]
556559
fn ordering() {
557560
assert!(UUID_1 < UUID_2);
558561

crates/bevy_asset/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
//! This trait mirrors [`AssetLoader`] in structure, and works in tandem with [`AssetWriter`](io::AssetWriter), which mirrors [`AssetReader`](io::AssetReader).
140140
141141
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
142+
#![deny(
143+
clippy::allow_attributes,
144+
clippy::allow_attributes_without_reason,
145+
reason = "See #17111; To be removed once all crates are in-line with these attributes"
146+
)]
142147
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
143148
#![doc(
144149
html_logo_url = "https://bevyengine.org/assets/icon.png",
@@ -1773,8 +1778,11 @@ mod tests {
17731778
#[derive(Asset, TypePath)]
17741779
pub struct TestAsset;
17751780

1776-
#[allow(dead_code)]
17771781
#[derive(Asset, TypePath)]
1782+
#[expect(
1783+
dead_code,
1784+
reason = "This exists to ensure that `#[derive(Asset)]` works on enums. The inner variants are known not to be used."
1785+
)]
17781786
pub enum EnumTestAsset {
17791787
Unnamed(#[dependency] Handle<TestAsset>),
17801788
Named {
@@ -1789,7 +1797,6 @@ mod tests {
17891797
Empty,
17901798
}
17911799

1792-
#[allow(dead_code)]
17931800
#[derive(Asset, TypePath)]
17941801
pub struct StructTestAsset {
17951802
#[dependency]
@@ -1798,7 +1805,6 @@ mod tests {
17981805
embedded: TestAsset,
17991806
}
18001807

1801-
#[allow(dead_code)]
18021808
#[derive(Asset, TypePath)]
18031809
pub struct TupleTestAsset(#[dependency] Handle<TestAsset>);
18041810
}

crates/bevy_asset/src/processor/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ impl AssetProcessor {
478478
self.set_state(ProcessorState::Finished).await;
479479
}
480480

481-
#[allow(unused)]
482481
#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
483482
async fn process_assets_internal<'scope>(
484483
&'scope self,

crates/bevy_asset/src/server/loaders.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,14 @@ mod tests {
351351

352352
use super::*;
353353

354-
// The compiler notices these fields are never read and raises a dead_code lint which kill CI.
355-
#[allow(dead_code)]
356354
#[derive(Asset, TypePath, Debug)]
357-
struct A(usize);
355+
struct A;
358356

359-
#[allow(dead_code)]
360357
#[derive(Asset, TypePath, Debug)]
361-
struct B(usize);
358+
struct B;
362359

363-
#[allow(dead_code)]
364360
#[derive(Asset, TypePath, Debug)]
365-
struct C(usize);
361+
struct C;
366362

367363
struct Loader<A: Asset, const N: usize, const E: usize> {
368364
sender: Sender<()>,

0 commit comments

Comments
 (0)