diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.rs b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.rs new file mode 100644 index 0000000000000..f10793a5f08a9 --- /dev/null +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.rs @@ -0,0 +1,31 @@ +use bevy_reflect::{Reflect, FromType}; +use std::marker::PhantomData; + +#[derive(Clone)] +struct ReflectMyTrait; + +impl FromType for ReflectMyTrait { + fn from_type() -> Self { + Self + } +} + +// Reason: where clause cannot be used with #[reflect(MyTrait)] +#[derive(Reflect)] +#[reflect(MyTrait, where)] +pub struct Foo { + value: String, + #[reflect(ignore)] + _marker: PhantomData, +} + +// Reason: where clause cannot be used with #[reflect(MyTrait)] +#[derive(Reflect)] +#[reflect(where, MyTrait)] +pub struct Bar { + value: String, + #[reflect(ignore)] + _marker: PhantomData, +} + +fn main() {} \ No newline at end of file diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.stderr b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.stderr new file mode 100644 index 0000000000000..10916ef3541ae --- /dev/null +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.stderr @@ -0,0 +1,11 @@ +error: expected identifier, found keyword `where` + --> tests/reflect_derive/custom_where.fail.rs:15:20 + | +15 | #[reflect(MyTrait, where)] + | ^^^^^ + +error: unexpected token + --> tests/reflect_derive/custom_where.fail.rs:24:16 + | +24 | #[reflect(where, MyTrait)] + | ^ diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.pass.rs b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.pass.rs new file mode 100644 index 0000000000000..f6c4eede76e74 --- /dev/null +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.pass.rs @@ -0,0 +1,31 @@ +use bevy_reflect::{Reflect, FromType}; +use std::marker::PhantomData; + +#[derive(Clone)] +struct ReflectMyTrait; + +impl FromType for ReflectMyTrait { + fn from_type() -> Self { + Self + } +} + +#[derive(Reflect)] +#[reflect(MyTrait)] +#[reflect(where)] +pub struct Foo { + value: String, + #[reflect(ignore)] + _marker: PhantomData, +} + +#[derive(Reflect)] +#[reflect(where)] +#[reflect(MyTrait)] +pub struct Bar { + value: String, + #[reflect(ignore)] + _marker: PhantomData, +} + +fn main() {}