Diagnostics for label traits (#17441)
# Objective
Diagnostics for labels don't suggest how to best implement them.
```
error[E0277]: the trait bound `Label: ScheduleLabel` is not satisfied
--> src/main.rs:15:35
|
15 | let mut sched = Schedule::new(Label);
| ------------- ^^^^^ the trait `ScheduleLabel` is not implemented for `Label`
| |
| required by a bound introduced by this call
|
= help: the trait `ScheduleLabel` is implemented for `Interned<(dyn ScheduleLabel + 'static)>`
note: required by a bound in `bevy_ecs::schedule::Schedule::new`
--> /home/vj/workspace/rust/bevy/crates/bevy_ecs/src/schedule/schedule.rs:297:28
|
297 | pub fn new(label: impl ScheduleLabel) -> Self {
| ^^^^^^^^^^^^^ required by this bound in `Schedule::new`
```
## Solution
`diagnostics::on_unimplemented` and `diagnostics::do_not_recommend`
## Showcase
New error message:
```
error[E0277]: the trait bound `Label: ScheduleLabel` is not satisfied
--> src/main.rs:15:35
|
15 | let mut sched = Schedule::new(Label);
| ------------- ^^^^^ the trait `ScheduleLabel` is not implemented for `Label`
| |
| required by a bound introduced by this call
|
= note: consider annotating `Label` with `#[derive(ScheduleLabel)]`
note: required by a bound in `bevy_ecs::schedule::Schedule::new`
--> /home/vj/workspace/rust/bevy/crates/bevy_ecs/src/schedule/schedule.rs:297:28
|
297 | pub fn new(label: impl ScheduleLabel) -> Self {
| ^^^^^^^^^^^^^ required by this bound in `Schedule::new`
```
This commit is contained in:
parent
ebbd961739
commit
a7051a4815
@ -32,6 +32,9 @@ use std::{
|
||||
|
||||
bevy_ecs::define_label!(
|
||||
/// A strongly-typed class of labels used to identify an [`App`].
|
||||
#[diagnostic::on_unimplemented(
|
||||
note = "consider annotating `{Self}` with `#[derive(AppLabel)]`"
|
||||
)]
|
||||
AppLabel,
|
||||
APP_LABEL_INTERNER
|
||||
);
|
||||
|
||||
@ -20,12 +20,18 @@ use crate::{
|
||||
|
||||
define_label!(
|
||||
/// A strongly-typed class of labels used to identify a [`Schedule`](crate::schedule::Schedule).
|
||||
#[diagnostic::on_unimplemented(
|
||||
note = "consider annotating `{Self}` with `#[derive(ScheduleLabel)]`"
|
||||
)]
|
||||
ScheduleLabel,
|
||||
SCHEDULE_LABEL_INTERNER
|
||||
);
|
||||
|
||||
define_label!(
|
||||
/// Types that identify logical groups of systems.
|
||||
#[diagnostic::on_unimplemented(
|
||||
note = "consider annotating `{Self}` with `#[derive(SystemSet)]`"
|
||||
)]
|
||||
SystemSet,
|
||||
SYSTEM_SET_INTERNER,
|
||||
extra_methods: {
|
||||
|
||||
@ -14,6 +14,9 @@ use super::{EdgeExistence, InternedRenderLabel, IntoRenderNodeArray};
|
||||
pub use bevy_render_macros::RenderSubGraph;
|
||||
|
||||
define_label!(
|
||||
#[diagnostic::on_unimplemented(
|
||||
note = "consider annotating `{Self}` with `#[derive(RenderSubGraph)]`"
|
||||
)]
|
||||
/// A strongly-typed class of labels used to identify a [`SubGraph`] in a render graph.
|
||||
RenderSubGraph,
|
||||
RENDER_SUB_GRAPH_INTERNER
|
||||
|
||||
@ -23,6 +23,9 @@ pub use bevy_render_macros::RenderLabel;
|
||||
use super::{InternedRenderSubGraph, RenderSubGraph};
|
||||
|
||||
define_label!(
|
||||
#[diagnostic::on_unimplemented(
|
||||
note = "consider annotating `{Self}` with `#[derive(RenderLabel)]`"
|
||||
)]
|
||||
/// A strongly-typed class of labels used to identify a [`Node`] in a render graph.
|
||||
RenderLabel,
|
||||
RENDER_LABEL_INTERNER
|
||||
|
||||
Loading…
Reference in New Issue
Block a user