#rust shows the wrong error when violating generic plugin trait bounds.

2 messages · Page 1 of 1 (latest)

loud orchid
#

I am trying to create plugins generically for my library. However, whenever trait bounds for the library's generic plugin implementations, I get a trait bound error for violating

the trait bound `SerializeQueryFor<<generic>, <generic>, <generic> bevy_app::plugin::sealed::Plugins<_>` is not satisfied

E.G: Given the below code. SerializeQueryFor has had most of its actual bounds commented out, but for illustrative purpose, I added the GetTypeRegistration bound. The error I should be something along the lines of,

the trait bound "GetTypeRegistration", is not satisfied for JointFlag

but instead, I get the first error for not satisfying Plugins<_>, regardless of actual violated trait bound.

#[derive(Component, Default)]
pub struct JointFlag {
    ... rest of impl
}

pub struct SerializeQueryFor<S, T, U> {
    query: PhantomData<fn() -> S>,
    thing: PhantomData<fn() -> T>,
    wrapper_thing: PhantomData<fn() -> U>,
}

impl<S,T,U> Plugin for SerializeQueryFor<S, T, U>
    where
        S: 'static,// + WorldQuery + for<'a, 'b> AssociatedEntity<&'b <<S as WorldQuery>::ReadOnly as WorldQuery>::Item<'a>>,
        T: 'static,// + Component + for<'a, 'b> From<&'b <<S as WorldQuery>::ReadOnly as WorldQuery>::Item<'a>>,
        U: 'static + Component + for<'a> From<&'a T> + GetTypeRegistration
{
    fn build(&self, app: &mut App) {
       ...rest of impl
    }
}
... in app
.add_plugins(SerializeQueryFor::<Linkage, ImpulseJoint, JointFlag>::default())

this problem with showing violating plugins<_>, instead of the actual violated trait bound, is making debugging my plugin generator difficult. Any way to fix this?

limber geyser
#

I know this was posted last year, but thought to add my related problem:

Basically that error (at least in my case) happens when your trait wasn't implemented for the generic type given in the add_plugins call. The error seems to have no hint to the actual problem.