Skip to content

Commit 65b1c56

Browse files
committed
Add remote FromReflect to compile tests
1 parent de29c7f commit 65b1c56

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,40 @@ mod external_crate {
88
mod missing_attribute {
99
use bevy_reflect::{reflect_remote, Reflect};
1010

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

17-
#[reflect_remote(super::external_crate::TheirInner<T>)]
17+
#[reflect_remote(super::external_crate::TheirInner<T>, FromReflect)]
1818
struct MyInner<T: Reflect>(pub T);
1919
}
2020

2121
mod incorrect_inner_type {
2222
use bevy_reflect::{reflect_remote, Reflect};
2323

24-
#[reflect_remote(super::external_crate::TheirOuter<T>)]
24+
#[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
2525
struct MyOuter<T: Reflect> {
2626
// Reason: Should not use `MyInner<T>` directly
2727
pub inner: MyInner<T>,
2828
}
2929

30-
#[reflect_remote(super::external_crate::TheirInner<T>)]
30+
#[reflect_remote(super::external_crate::TheirInner<T>, FromReflect)]
3131
struct MyInner<T: Reflect>(pub T);
3232
}
3333

3434
mod mismatched_remote_type {
3535
use bevy_reflect::{reflect_remote, Reflect};
3636

37-
#[reflect_remote(super::external_crate::TheirOuter<T>)]
37+
#[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
3838
struct MyOuter<T: Reflect> {
3939
// Reason: Should be `MyInner<T>`
4040
#[reflect(remote = "MyOuter<T>")]
4141
pub inner: super::external_crate::TheirInner<T>,
4242
}
4343

44-
#[reflect_remote(super::external_crate::TheirInner<T>)]
44+
#[reflect_remote(super::external_crate::TheirInner<T>, FromReflect)]
4545
struct MyInner<T: Reflect>(pub T);
4646
}
4747

crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.stderr

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ note: required by a bound in `NamedField::new`
2323
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
2424
--> tests/reflect_remote/nested.fail.rs:11:5
2525
|
26-
11 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
26+
11 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
2828
|
2929
= help: the following other types implement trait `Reflect`:
3030
&'static Path
@@ -42,8 +42,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
4242
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
4343
--> tests/reflect_remote/nested.fail.rs:11:5
4444
|
45-
11 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
46-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
45+
11 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
4747
|
4848
= help: the following other types implement trait `Reflect`:
4949
&'static Path
@@ -61,8 +61,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
6161
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
6262
--> tests/reflect_remote/nested.fail.rs:11:5
6363
|
64-
11 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
65-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
64+
11 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
6666
|
6767
= help: the following other types implement trait `Reflect`:
6868
&'static Path
@@ -76,11 +76,22 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
7676
and $N others
7777
= note: this error originates in the attribute macro `reflect_remote` (in Nightly builds, run with -Z macro-backtrace for more info)
7878

79+
error[E0308]: `?` operator has incompatible types
80+
--> tests/reflect_remote/nested.fail.rs:24:5
81+
|
82+
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
83+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `incorrect_inner_type::MyInner`
84+
|
85+
= note: `?` operator cannot convert from `incorrect_inner_type::MyInner<T>` to `TheirInner<T>`
86+
= note: expected struct `TheirInner<T>`
87+
found struct `incorrect_inner_type::MyInner<T>`
88+
= note: this error originates in the attribute macro `reflect_remote` (in Nightly builds, run with -Z macro-backtrace for more info)
89+
7990
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
8091
--> tests/reflect_remote/nested.fail.rs:24:5
8192
|
82-
24 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
83-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
93+
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
94+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
8495
|
8596
= help: the following other types implement trait `Reflect`:
8697
&'static Path
@@ -98,8 +109,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
98109
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
99110
--> tests/reflect_remote/nested.fail.rs:24:5
100111
|
101-
24 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
102-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
112+
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
113+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
103114
|
104115
= help: the following other types implement trait `Reflect`:
105116
&'static Path
@@ -117,8 +128,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
117128
error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
118129
--> tests/reflect_remote/nested.fail.rs:24:5
119130
|
120-
24 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
121-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
131+
24 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
132+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner<T>`
122133
|
123134
= help: the following other types implement trait `Reflect`:
124135
&'static Path
@@ -135,8 +146,8 @@ error[E0277]: the trait bound `TheirInner<T>: Reflect` is not satisfied
135146
error[E0308]: mismatched types
136147
--> tests/reflect_remote/nested.fail.rs:37:5
137148
|
138-
37 | #[reflect_remote(super::external_crate::TheirOuter<T>)]
139-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `TheirOuter`
149+
37 | #[reflect_remote(super::external_crate::TheirOuter<T>, FromReflect)]
150+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `TheirOuter`
140151
...
141152
41 | pub inner: super::external_crate::TheirInner<T>,
142153
| ------------------------------------ expected due to this

crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ mod external_crate {
77
pub struct TheirInner<T>(pub T);
88
}
99

10-
#[reflect_remote(external_crate::TheirOuter<T>)]
10+
#[reflect_remote(external_crate::TheirOuter<T>, FromReflect)]
1111
struct MyOuter<T: Reflect> {
1212
#[reflect(remote = "MyInner<T>")]
1313
pub inner: external_crate::TheirInner<T>,
1414
}
1515

16-
#[reflect_remote(external_crate::TheirInner<T>)]
16+
#[reflect_remote(external_crate::TheirInner<T>, FromReflect)]
1717
struct MyInner<T: Reflect>(pub T);
1818

1919
fn main() {}

0 commit comments

Comments
 (0)