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 Jan 3, 2023
1 parent 62f7d84 commit 3462335
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 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
Expand Up @@ -23,8 +23,8 @@ note: required by a bound in `NamedField::new`
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
--> tests/reflect_remote/nested.fail.rs:11:5
|
11 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
11 | #[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 @@ -42,8 +42,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:11:5
|
11 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
11 | #[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 @@ -61,8 +61,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:11:5
|
11 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
11 | #[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 @@ -76,11 +76,22 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
and $N others
= note: this error originates in the attribute macro `reflect_remote` (in Nightly builds, run with -Z macro-backtrace for more info)

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 @@ -98,8 +109,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 @@ -117,8 +128,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 @@ -135,8 +146,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 3462335

Please sign in to comment.