Open martindemello opened 3 years ago
This was one of the issues I ran into when learning Bevy, and it's one of the ones that hasn't gone away. I'm better at diagnosing these issues, but it's too easy to accidentally leave off or add a &
or mut
, and spotting the problem always feels like finding a needle in a haystack. I'm porting my code to "pre-0.5" now and it's just the same thing over again with new rules.
Documentation is a good short term fix, but I would suggest looking for technical ways to improve the error message here.
still a problem except nowadays the error message is
error[E0277]: the trait bound `for<'a> fn(&'a mut MyResource) {invalid_system}: IntoSystemConfigs<_>` is not satisfied
--> src/main.rs:8:30
|
8 | app.add_systems(Startup, invalid_system);
| ----------- ^^^^^^^^^^^^^^ the trait `IntoSystem<(), (), _>` is not implemented for fn item `for<'a> fn(&'a mut MyResource) {invalid_system}`, which is required by `for<'a> fn(&'a mut MyResource) {invalid_system}: IntoSystemConfigs<_>`
| |
| required by a bound introduced by this call
|
Getting the wrong signature for a function leads to a complex error message like
I managed to solve my issue thanks to this reddit comment (specifically I had the arg
state: &mut ResMut<GameState>
where bevy wantedmut state: ResMut<GameState>
), but that was literally the only helpful documentation I could find.The error and a set of guidelines for what an acceptable fn signature is should be documented somewhere in the bevy book, perhaps in the
Troubleshooting
section to begin with.