In summary: the missing_reflect lint pass currently emits the #[derive(Reflect)] suggestion as MachineApplicable, but this may not always be the case. Some fields of structs cannot be reflected, so deriving Reflect will fail.
Quoting @MrGVSV:
For checking all fields, should I just check that they also implement Reflect? Or is there other criteria that I should look for?
So this is where it can get a little confusing 😅
Always Required
The traits that are always mandatory are Any, Send, and Sync.
Then for active fields (i.e. fields not marked #[reflect(ignore)]), we require that they implement TypePath, MaybeTyped, and RegisterForReflection. The latter two are hidden traits that allow us to handle dynamic types, which can't implement Typed and GetTypeRegistration, respectively.
Lastly, all active fields must implement either FromReflect or, if #[reflect(from_reflect = false)], Reflect1.
Since FromReflect requires Reflect1, it should be fine to just check for PartialReflect. But if any field doesn't implement FromReflect, the container type will need to also add the #[reflect(from_reflect = false)] opt-out.
So if we did want to handle cases with un-reflectable fields, it would be best if we checked for all of these. But if it's simpler to start with, I'd say the biggest one to check for is just Reflect1.
There are other attributes to help users control these bounds (e.g. #[reflect(no_field_bounds)], #[reflect(where T: Foo)], etc.), but I don't think a linter should recommend them just generally.
For a short-term solution, the lint pass should check that all fields of a struct implement Reflect, and use that to determine the Applicability. In the future, the lint should do the more complicated checks that @MrGVSV described and suggest using #[reflect(ignore)] for bad fields.
Please see https://github.com/TheBevyFlock/bevy_cli/pull/139#issuecomment-2412365790, https://github.com/TheBevyFlock/bevy_cli/pull/139#issuecomment-2412388332, and https://github.com/TheBevyFlock/bevy_cli/pull/139#issuecomment-2412472766 for context.
In summary: the
missing_reflect
lint pass currently emits the#[derive(Reflect)]
suggestion asMachineApplicable
, but this may not always be the case. Some fields of structs cannot be reflected, so derivingReflect
will fail.Quoting @MrGVSV:
For a short-term solution, the lint pass should check that all fields of a struct implement
Reflect
, and use that to determine theApplicability
. In the future, the lint should do the more complicated checks that @MrGVSV described and suggest using#[reflect(ignore)]
for bad fields.