Closed
Description
What problem does this solve or what need does it fill?
Bevy's error messages for invalid inputs for systems and queries that take SystemParam
, QueryData
or QueryFilter
are terrible: users get a terrible error message saying that the trait isn't implemented for the whole tuple and suggesting a bunch of irrelevant tuples with generic types.
For upstream reports of what these errors look like, please see:
- Bevy malformed system errors are extremely unhelpful due to macro-magic rust-lang/rust#89681
- Unhelpful error message for malformed Bevy Query type parameters rust-lang/rust#89680
- No "consider borrowing here" suggestion for method on complex trait bound rust-lang/rust#89679
- Don't treat tuple struct types as functions in diagnostics rust-lang/rust#114247
What solution would you like?
Use the soon-to-be-stabilized diagnostic
attribute on our key traits, and manually provide more helpful error messages.
#[diagnostic::on_unimplemented(
message = "My Message for `ImportantTrait<{A}>` is not implemented for `{Self}`",
label = "My Label",
note = "Note 1",
note = "Note 2"
)]
trait ImportantTrait<A> {}
rust-lang/rust#119888 is the stabilization PR which goes over more details of how this works: this will not be available until Rust 1.78.
What alternative(s) have you considered?
- Add variadic generics to upstream Rust (one day).
- Use a macro to determine these things that needs to be added to every system.
bevy_check
by @jakobhellermann does this, and is essential prior art.
Additional context
This was brought to my attention by George Semmler on Mastodon.