From 65b1c56ed31eaa701d4bc34b00ba8c1599e90aa4 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Mon, 2 Jan 2023 21:25:34 -0800 Subject: [PATCH] Add remote FromReflect to compile tests --- .../tests/reflect_remote/nested.fail.rs | 12 +++--- .../tests/reflect_remote/nested.fail.stderr | 39 ++++++++++++------- .../tests/reflect_remote/nested.pass.rs | 4 +- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.rs b/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.rs index e7f40bd3c0c072..1f3df07827deba 100644 --- a/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.rs +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.rs @@ -8,40 +8,40 @@ mod external_crate { mod missing_attribute { use bevy_reflect::{reflect_remote, Reflect}; - #[reflect_remote(super::external_crate::TheirOuter)] + #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] struct MyOuter { // Reason: Missing `#[reflect(remote = "...")]` attribute pub inner: super::external_crate::TheirInner, } - #[reflect_remote(super::external_crate::TheirInner)] + #[reflect_remote(super::external_crate::TheirInner, FromReflect)] struct MyInner(pub T); } mod incorrect_inner_type { use bevy_reflect::{reflect_remote, Reflect}; - #[reflect_remote(super::external_crate::TheirOuter)] + #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] struct MyOuter { // Reason: Should not use `MyInner` directly pub inner: MyInner, } - #[reflect_remote(super::external_crate::TheirInner)] + #[reflect_remote(super::external_crate::TheirInner, FromReflect)] struct MyInner(pub T); } mod mismatched_remote_type { use bevy_reflect::{reflect_remote, Reflect}; - #[reflect_remote(super::external_crate::TheirOuter)] + #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] struct MyOuter { // Reason: Should be `MyInner` #[reflect(remote = "MyOuter")] pub inner: super::external_crate::TheirInner, } - #[reflect_remote(super::external_crate::TheirInner)] + #[reflect_remote(super::external_crate::TheirInner, FromReflect)] struct MyInner(pub T); } diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.stderr b/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.stderr index 15179add33ae3a..6ada49f7764b82 100644 --- a/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.stderr +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.fail.stderr @@ -23,8 +23,8 @@ note: required by a bound in `NamedField::new` error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied --> tests/reflect_remote/nested.fail.rs:11:5 | -11 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` +11 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` | = help: the following other types implement trait `Reflect`: &'static Path @@ -42,8 +42,8 @@ error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied --> tests/reflect_remote/nested.fail.rs:11:5 | -11 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` +11 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` | = help: the following other types implement trait `Reflect`: &'static Path @@ -61,8 +61,8 @@ error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied --> tests/reflect_remote/nested.fail.rs:11:5 | -11 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` +11 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` | = help: the following other types implement trait `Reflect`: &'static Path @@ -76,11 +76,22 @@ error[E0277]: the trait bound `TheirInner: 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, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `incorrect_inner_type::MyInner` + | + = note: `?` operator cannot convert from `incorrect_inner_type::MyInner` to `TheirInner` + = note: expected struct `TheirInner` + found struct `incorrect_inner_type::MyInner` + = 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: Reflect` is not satisfied --> tests/reflect_remote/nested.fail.rs:24:5 | -24 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` +24 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` | = help: the following other types implement trait `Reflect`: &'static Path @@ -98,8 +109,8 @@ error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied --> tests/reflect_remote/nested.fail.rs:24:5 | -24 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` +24 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` | = help: the following other types implement trait `Reflect`: &'static Path @@ -117,8 +128,8 @@ error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied --> tests/reflect_remote/nested.fail.rs:24:5 | -24 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` +24 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Reflect` is not implemented for `TheirInner` | = help: the following other types implement trait `Reflect`: &'static Path @@ -135,8 +146,8 @@ error[E0277]: the trait bound `TheirInner: Reflect` is not satisfied error[E0308]: mismatched types --> tests/reflect_remote/nested.fail.rs:37:5 | -37 | #[reflect_remote(super::external_crate::TheirOuter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `TheirOuter` +37 | #[reflect_remote(super::external_crate::TheirOuter, FromReflect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TheirInner`, found struct `TheirOuter` ... 41 | pub inner: super::external_crate::TheirInner, | ------------------------------------ expected due to this diff --git a/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.pass.rs b/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.pass.rs index 013358e888d2db..10d7c28480328b 100644 --- a/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.pass.rs +++ b/crates/bevy_reflect_compile_fail_tests/tests/reflect_remote/nested.pass.rs @@ -7,13 +7,13 @@ mod external_crate { pub struct TheirInner(pub T); } -#[reflect_remote(external_crate::TheirOuter)] +#[reflect_remote(external_crate::TheirOuter, FromReflect)] struct MyOuter { #[reflect(remote = "MyInner")] pub inner: external_crate::TheirInner, } -#[reflect_remote(external_crate::TheirInner)] +#[reflect_remote(external_crate::TheirInner, FromReflect)] struct MyInner(pub T); fn main() {}