-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
bevy_asset: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
#17113
bevy_asset: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
#17113
Conversation
#[expect( | ||
dead_code, | ||
reason = "This exists to ensure that `#[derive(Asset)]` works on enums. The inner variants are known not to be used." | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea why this only lints on the enum test case, despite the struct test cases also being unused.
#[derive(Asset, TypePath, Debug)] | ||
struct A(usize); | ||
struct A; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you're wondering: I checked and double-checked to make sure that removing these usize
fields wouldn't affect tests.
If they affect tests, I didn't see it during my testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the tests are meant to test specifically unit struct assets. Unit struct assets don't sound very useful anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but... The tests compile and finish successfully either way.
Really, the (usize)
only confuses people into thinking that we're somehow constructing instances of the structs. Except, we're not - the structs are only used as type parameters.
If we start needing a value, they can be added back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that as far as I can see there seems to be no behavior in the tests hinging on the structs having any fields. However, idk if they're relevant for TypeId
calculations.
It would be best to ask someone who wrote this or knows about reflection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IQuick143 I don't believe they're relevant for TypeId
calculations: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=99bbd15c51d685da51caa2a4beecf51b
I mean, it appears that changing one to include (usize)
does change its TypeId
- but two unit structs still have two different TypeId
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I think this fix is good :)
#[derive(Asset, TypePath, Debug)] | ||
struct A(usize); | ||
struct A; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the tests are meant to test specifically unit struct assets. Unit struct assets don't sound very useful anyway.
In benches, we silence dead code warnings due to similar dead_code unit tests in this PR. |
It's fine to me if we fix the dead code warning by removing the fields, but I wonder if it might make sense to instead use those fields in the unit tests. If not, nevermind me. |
@BenjaminBrienen Adding a new test that uses those fields would probably make more sense - but the addition of tests is out-of-scope for this PR. |
#[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
#![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
a1bf6e0
to
53bc757
Compare
Objective
clippy::allow_attributes
andclippy::allow_attributes_without_reason
lints #17111Solution
Set the
clippy::allow_attributes
andclippy::allow_attributes_without_reason
lints todeny
, and bringbevy_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
andcargo test --package bevy_asset --features multi_threaded
were run, and no errors were encountered.