-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-ReviewNeeds reviewer attention (from anyone!) to move forwardNeeds reviewer attention (from anyone!) to move forwardX-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
Milestone
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.
MrGVSV, SpecificProtagonist, NyxAlexandra, Jondolf, stan4cb and 2 more
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-ReviewNeeds reviewer attention (from anyone!) to move forwardNeeds reviewer attention (from anyone!) to move forwardX-UncontroversialThis work is generally agreed uponThis work is generally agreed upon