-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compile fail tests for custom where
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use bevy_reflect::{Reflect, FromType}; | ||
use std::marker::PhantomData; | ||
|
||
#[derive(Clone)] | ||
struct ReflectMyTrait; | ||
|
||
impl<T> FromType<T> for ReflectMyTrait { | ||
fn from_type() -> Self { | ||
Self | ||
} | ||
} | ||
|
||
// Reason: where clause cannot be used with #[reflect(MyTrait)] | ||
#[derive(Reflect)] | ||
#[reflect(MyTrait, where)] | ||
pub struct Foo<T> { | ||
value: String, | ||
#[reflect(ignore)] | ||
_marker: PhantomData<T>, | ||
} | ||
|
||
// Reason: where clause cannot be used with #[reflect(MyTrait)] | ||
#[derive(Reflect)] | ||
#[reflect(where, MyTrait)] | ||
pub struct Bar<T> { | ||
value: String, | ||
#[reflect(ignore)] | ||
_marker: PhantomData<T>, | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.fail.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)] | ||
| ^ |
31 changes: 31 additions & 0 deletions
31
crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/custom_where.pass.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use bevy_reflect::{Reflect, FromType}; | ||
use std::marker::PhantomData; | ||
|
||
#[derive(Clone)] | ||
struct ReflectMyTrait; | ||
|
||
impl<T> FromType<T> for ReflectMyTrait { | ||
fn from_type() -> Self { | ||
Self | ||
} | ||
} | ||
|
||
#[derive(Reflect)] | ||
#[reflect(MyTrait)] | ||
#[reflect(where)] | ||
pub struct Foo<T> { | ||
value: String, | ||
#[reflect(ignore)] | ||
_marker: PhantomData<T>, | ||
} | ||
|
||
#[derive(Reflect)] | ||
#[reflect(where)] | ||
#[reflect(MyTrait)] | ||
pub struct Bar<T> { | ||
value: String, | ||
#[reflect(ignore)] | ||
_marker: PhantomData<T>, | ||
} | ||
|
||
fn main() {} |