From f40347e0402a5a2ab884ca036afcfaa4fa7d4df8 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Mon, 27 Mar 2023 18:41:52 -0700 Subject: [PATCH] Fix compile fail test --- .../tests/reflect_derive/generics.fail.rs | 6 +-- .../tests/reflect_derive/generics.fail.stderr | 40 +++++++++++++------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.rs b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.rs index 964d784d354d0..119867e6db459 100644 --- a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.rs +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.rs @@ -1,4 +1,4 @@ -use bevy_reflect::Reflect; +use bevy_reflect::{GetField, Reflect, Struct}; #[derive(Reflect)] struct Foo { @@ -9,7 +9,7 @@ struct Foo { struct NoReflect(f32); fn main() { - let mut foo: Box = Box::new(Foo:: { a: NoReflect(42.0) }); + let mut foo: Box = Box::new(Foo:: { a: NoReflect(42.0) }); // foo doesn't implement Reflect because NoReflect doesn't implement Reflect foo.get_field::("a").unwrap(); -} \ No newline at end of file +} diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.stderr b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.stderr index 568f5f8b6d997..c12f6d59feeaa 100644 --- a/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.stderr +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_derive/generics.fail.stderr @@ -1,16 +1,32 @@ -error[E0599]: no method named `get_field` found for struct `Box<(dyn Reflect + 'static)>` in the current scope - --> tests/reflect_derive/generics.fail.rs:14:9 - | -14 | foo.get_field::("a").unwrap(); - | ^^^^^^^^^ method not found in `Box` - error[E0277]: the trait bound `NoReflect: Reflect` is not satisfied - --> tests/reflect_derive/generics.fail.rs:12:37 + --> tests/reflect_derive/generics.fail.rs:14:21 + | +14 | foo.get_field::("a").unwrap(); + | ^^^^^^^^^ the trait `Reflect` is not implemented for `NoReflect` + | + = help: the following other types implement trait `Reflect`: + &'static Path + () + (A, B) + (A, B, C) + (A, B, C, D) + (A, B, C, D, E) + (A, B, C, D, E, F) + (A, B, C, D, E, F, G) + and $N others +note: required by a bound in `bevy_reflect::GetField::get_field` + --> /Users/ginovalente/Projects/Git/rust/bevy/crates/bevy_reflect/src/struct_trait.rs:243:21 + | +243 | fn get_field(&self, name: &str) -> Option<&T>; + | ^^^^^^^ required by this bound in `GetField::get_field` + +error[E0277]: the trait bound `NoReflect: GetTypeRegistration` is not satisfied + --> tests/reflect_derive/generics.fail.rs:12:36 | -12 | let mut foo: Box = Box::new(Foo:: { a: NoReflect(42.0) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `NoReflect` +12 | let mut foo: Box = Box::new(Foo:: { a: NoReflect(42.0) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `GetTypeRegistration` is not implemented for `NoReflect` | - = help: the following other types implement trait `Reflect`: + = help: the following other types implement trait `GetTypeRegistration`: &'static Path () (A, B) @@ -20,12 +36,12 @@ error[E0277]: the trait bound `NoReflect: Reflect` is not satisfied (A, B, C, D, E, F) (A, B, C, D, E, F, G) and $N others -note: required for `Foo` to implement `Reflect` +note: required for `Foo` to implement `bevy_reflect::Struct` --> tests/reflect_derive/generics.fail.rs:3:10 | 3 | #[derive(Reflect)] | ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro 4 | struct Foo { | ^^^^^^ - = note: required for the cast from `Foo` to the object type `dyn Reflect` + = note: required for the cast from `Foo` to the object type `dyn bevy_reflect::Struct` = note: this error originates in the derive macro `Reflect` (in Nightly builds, run with -Z macro-backtrace for more info)