Skip to content

Commit a857552

Browse files
committed
Fix compile fail test
1 parent caa88b8 commit a857552

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy_reflect::Reflect;
1+
use bevy_reflect::{GetField, Reflect, Struct};
22

33
#[derive(Reflect)]
44
struct Foo<T> {
@@ -9,7 +9,7 @@ struct Foo<T> {
99
struct NoReflect(f32);
1010

1111
fn main() {
12-
let mut foo: Box<dyn Reflect> = Box::new(Foo::<NoReflect> { a: NoReflect(42.0) });
12+
let mut foo: Box<dyn Struct> = Box::new(Foo::<NoReflect> { a: NoReflect(42.0) });
1313
// foo doesn't implement Reflect because NoReflect doesn't implement Reflect
1414
foo.get_field::<NoReflect>("a").unwrap();
15-
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1-
error[E0599]: no method named `get_field` found for struct `Box<(dyn Reflect + 'static)>` in the current scope
2-
--> tests/reflect_derive/generics.fail.rs:14:9
3-
|
4-
14 | foo.get_field::<NoReflect>("a").unwrap();
5-
| ^^^^^^^^^ method not found in `Box<dyn Reflect>`
6-
71
error[E0277]: the trait bound `NoReflect: Reflect` is not satisfied
8-
--> tests/reflect_derive/generics.fail.rs:12:37
2+
--> tests/reflect_derive/generics.fail.rs:14:21
3+
|
4+
14 | foo.get_field::<NoReflect>("a").unwrap();
5+
| ^^^^^^^^^ the trait `Reflect` is not implemented for `NoReflect`
6+
|
7+
= help: the following other types implement trait `Reflect`:
8+
&'static Path
9+
()
10+
(A, B)
11+
(A, B, C)
12+
(A, B, C, D)
13+
(A, B, C, D, E)
14+
(A, B, C, D, E, F)
15+
(A, B, C, D, E, F, G)
16+
and $N others
17+
note: required by a bound in `bevy_reflect::GetField::get_field`
18+
--> /Users/ginovalente/Projects/Git/rust/bevy/crates/bevy_reflect/src/struct_trait.rs:243:21
19+
|
20+
243 | fn get_field<T: Reflect>(&self, name: &str) -> Option<&T>;
21+
| ^^^^^^^ required by this bound in `GetField::get_field`
22+
23+
error[E0277]: the trait bound `NoReflect: GetTypeRegistration` is not satisfied
24+
--> tests/reflect_derive/generics.fail.rs:12:36
925
|
10-
12 | let mut foo: Box<dyn Reflect> = Box::new(Foo::<NoReflect> { a: NoReflect(42.0) });
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `NoReflect`
26+
12 | let mut foo: Box<dyn Struct> = Box::new(Foo::<NoReflect> { a: NoReflect(42.0) });
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `GetTypeRegistration` is not implemented for `NoReflect`
1228
|
13-
= help: the following other types implement trait `Reflect`:
29+
= help: the following other types implement trait `GetTypeRegistration`:
1430
&'static Path
1531
()
1632
(A, B)
@@ -20,12 +36,12 @@ error[E0277]: the trait bound `NoReflect: Reflect` is not satisfied
2036
(A, B, C, D, E, F)
2137
(A, B, C, D, E, F, G)
2238
and $N others
23-
note: required for `Foo<NoReflect>` to implement `Reflect`
39+
note: required for `Foo<NoReflect>` to implement `bevy_reflect::Struct`
2440
--> tests/reflect_derive/generics.fail.rs:3:10
2541
|
2642
3 | #[derive(Reflect)]
2743
| ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
2844
4 | struct Foo<T> {
2945
| ^^^^^^
30-
= note: required for the cast from `Foo<NoReflect>` to the object type `dyn Reflect`
46+
= note: required for the cast from `Foo<NoReflect>` to the object type `dyn bevy_reflect::Struct`
3147
= note: this error originates in the derive macro `Reflect` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)