Skip to content

Commit

Permalink
Add remote FromReflect to compile tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGVSV committed Feb 7, 2023
1 parent 8d2268c commit 62a3bee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@ mod external_crate {
mod missing_attribute {
use bevy_reflect::{reflect_remote, Reflect};

#[reflect_remote(super::external_crate::TheirOuter<T>)]
#[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
struct MyOuter<T: Reflect> {
// Reason: Missing `#[reflect(remote = "...")]` attribute
pub inner: super::external_crate::TheirInner<T>,
}

#[reflect_remote(super::external_crate::TheirInner<T>)]
#[reflect_remote(super::external_crate::TheirInner<T>, FromReflect)]
struct MyInner<T: Reflect>(pub T);
}

mod incorrect_inner_type {
use bevy_reflect::{reflect_remote, Reflect};

#[reflect_remote(super::external_crate::TheirOuter<T>)]
#[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
struct MyOuter<T: Reflect> {
// Reason: Should not use `MyInner<T>` directly
pub inner: MyInner<T>,
}

#[reflect_remote(super::external_crate::TheirInner<T>)]
#[reflect_remote(super::external_crate::TheirInner<T>, FromReflect)]
struct MyInner<T: Reflect>(pub T);
}

mod mismatched_remote_type {
use bevy_reflect::{reflect_remote, Reflect};

#[reflect_remote(super::external_crate::TheirOuter<T>)]
#[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
struct MyOuter<T: Reflect> {
// Reason: Should be `MyInner<T>`
#[reflect(remote = "MyOuter<T>")]
pub inner: super::external_crate::TheirInner<T>,
}

#[reflect_remote(super::external_crate::TheirInner<T>)]
#[reflect_remote(super::external_crate::TheirInner<T>, FromReflect)]
struct MyInner<T: Reflect>(pub T);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
error[E0308]: `?` operator has incompatible types
--> tests/reflect_remote/nested.fail.rs:24:5
|
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `incorrect_inner_type::MyInner`
|
= note: `?` operator cannot convert from `incorrect_inner_type::MyInner<T>` to `TheirInner<T>`
= note: expected struct `TheirInner<T>`
found struct `incorrect_inner_type::MyInner<T>`
= note: this error originates in the attribute macro `reflect_remote` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
--> tests/reflect_remote/nested.fail.rs:24:5
|
24 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
|
= help: the following other types implement trait `Reflect`:
&'static Path
Expand All @@ -20,8 +31,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
--> tests/reflect_remote/nested.fail.rs:24:5
|
24 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
|
= help: the following other types implement trait `Reflect`:
&'static Path
Expand All @@ -39,8 +50,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
--> tests/reflect_remote/nested.fail.rs:24:5
|
24 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
|
= help: the following other types implement trait `Reflect`:
&'static Path
Expand All @@ -57,8 +68,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
error[E0308]: mismatched types
--> tests/reflect_remote/nested.fail.rs:37:5
|
37 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `TheirOuter`
37 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `TheirOuter`
...
41 | pub inner: super::external_crate::TheirInner<T>,
| ------------------------------------ expected due to this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ mod external_crate {
pub struct TheirInner<T>(pub T);
}

#[reflect_remote(external_crate::TheirOuter<T>)]
#[reflect_remote(external_crate::TheirOuter<T>, FromReflect)]
struct MyOuter<T: Reflect> {
#[reflect(remote = "MyInner<T>")]
pub inner: external_crate::TheirInner<T>,
}

#[reflect_remote(external_crate::TheirInner<T>)]
#[reflect_remote(external_crate::TheirInner<T>, FromReflect)]
struct MyInner<T: Reflect>(pub T);

fn main() {}

0 comments on commit 62a3bee

Please sign in to comment.