Skip to content

Commit 4677292

Browse files
committed
Added custom diagnostic::on_unimplemented attributes
1 parent 2539b92 commit 4677292

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/bevy_reflect/src/cast.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ use bevy_reflect_derive::impl_type_path;
6868
///
6969
/// [`dyn PartialReflect`]: PartialReflect
7070
/// [derives `Reflect`]: derive@crate::Reflect
71+
#[diagnostic::on_unimplemented(
72+
message = "`{Self}` does not implement `CastPartialReflect` so cannot be cast to `dyn PartialReflect`",
73+
note = "consider annotating `{Self}` with `#[derive(Reflect)]`"
74+
)]
7175
pub trait CastPartialReflect: Send + Sync + 'static {
7276
/// Casts this type to a [`dyn PartialReflect`] reference.
7377
///
@@ -112,6 +116,10 @@ impl<T: ?Sized + CastPartialReflect> CastPartialReflect for Box<T> {
112116
///
113117
/// [`dyn Reflect`]: Reflect
114118
/// [derives `Reflect`]: derive@crate::Reflect
119+
#[diagnostic::on_unimplemented(
120+
message = "`{Self}` does not implement `CastReflect` so cannot be cast to `dyn Reflect`",
121+
note = "consider annotating `{Self}` with `#[derive(Reflect)]`"
122+
)]
115123
pub trait CastReflect: CastPartialReflect {
116124
/// Casts this type to a [`dyn Reflect`] reference.
117125
///

0 commit comments

Comments
 (0)