TheBevyFlock / bevy_cli

A Bevy CLI tool and linter.
https://thebevyflock.github.io/bevy_cli/
Apache License 2.0
33 stars 6 forks source link

Lint suggestion: change detection on a ZST #100

Open alice-i-cecile opened 1 month ago

alice-i-cecile commented 1 month ago

You can technically call .is_changed or use Changed on components and resources with no data. This is cursed, and likely to be removed eventually.

BD103 commented 1 month ago

Looks like this can be done with approx_ty_size(), though LayoutOff looks promising as well. LayoutCalculator and Abi seem like even better tells for ZSTs, but they might be more difficult to use.

I think this is a good idea! What specific types am I looking for? Anything before Ref and Mut?

alice-i-cecile commented 1 month ago

Any of the methods on ComponentTicks being called on a ZST, Ref<ZST>, ChangeTrackers<ZST> or Changed<ZST>. This is probably a Suspicious category lint: it technically works but...

janhohenheim commented 1 month ago

Yeah, I'd say the only place where you want to do this is macros, and there it's commonplace to disable lints already.