Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to #[derive(ActionLike)] on minimal enum #404

Closed
Austreelis opened this issue Oct 26, 2023 · 6 comments
Closed

Fail to #[derive(ActionLike)] on minimal enum #404

Austreelis opened this issue Oct 26, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@Austreelis
Copy link

Austreelis commented Oct 26, 2023

Version

lwim: fc3e348
bevy: a830530b
(both latest main at the time of writing)

Operating system & version

Linux 6.1.57 NixOS SMP PREEMPT_DYNAMIC x86_64 GNU/Linux

What you did

Make a simple action enum from the minimal example:

// lib.rs

use bevy::reflect::Reflect;
use leafwing_input_manager::Actionlike;

#[derive(Actionlike, Reflect, Hash, PartialEq, Eq, Clone, Copy, Debug)]
pub enum Action {
    Move,
    Jump,
}

then build it with cargo build --lib.

What you expected to happen

Build succeeds.

What actually happened

error[E0277]: the trait bound `test::Action: bevy_reflect::type_path::TypePath` is not satisfied
  --> src/test.rs:7:10
   |
7  | pub enum Action {
   |          ^^^^^^ the trait `bevy_reflect::type_path::TypePath` is not implemented for `test::Action`
   |
   = help: the following other types implement trait `bevy_reflect::type_path::TypePath`:
             bool
             char
             isize
             i8
             i16
             i32
             i64
             i128
           and 292 others
note: required by a bound in `Actionlike`
  --> ~/.cargo/git/checkouts/leafwing-input-manager-85f1d55581648fda/fc3e348/src/lib.rs:83:45
   |
83 | pub trait Actionlike: Send + Sync + Clone + TypePath + 'static {
   |                                             ^^^^^^^^ required by this bound in `Actionlike`
   = note: `Actionlike` is a "sealed trait", because to implement it you also need to implement `bevy_reflect::type_path::TypePath`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it

Additional information

rustc --version: rustc 1.73.0 (cc66ad468 2023-10-03) (stable)

This might be related to bevy #10228 (and thus be an upstream bug), but my suspicion only comes from the identical error message.

@Austreelis Austreelis added the bug Something isn't working label Oct 26, 2023
@alice-i-cecile
Copy link
Contributor

Hmm, that's really interesting. I'll try swapping directly to a Reflect requirement.

@alice-i-cecile
Copy link
Contributor

Can you test this out on the latest commit of #400 ? I've swapped to a Reflect bound there.

@Austreelis
Copy link
Author

Austreelis commented Oct 26, 2023

972978f still fails to build but this time because of Reflect failing to be implemented:

error[E0277]: the trait bound `test::Action: bevy_reflect::reflect::Reflect` is not satisfied
  --> src/test.rs:5:10
   |
5  | pub enum Action {
   |          ^^^^^^ the trait `bevy_reflect::reflect::Reflect` is not implemented for `test::Action`
   |
   = help: the following other types implement trait `bevy_reflect::reflect::Reflect`:
             bool
             char
             isize
             i8
             i16
             i32
             i64
             i128
           and 295 others
note: required by a bound in `leafwing_input_manager::Actionlike`
  --> ~/.cargo/git/checkouts/leafwing-input-manager-85f1d55581648fda/972978f/src/lib.rs:84:64
   |
84 | pub trait Actionlike: Eq + Hash + Send + Sync + Clone + Hash + Reflect + 'static {
   |                                                                ^^^^^^^ required by this bound in `Actionlike`
   = note: `Actionlike` is a "sealed trait", because to implement it you also need to implement `bevy_reflect::reflect::Reflect`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it

error[E0277]: the trait bound `test::Action: bevy_reflect::type_path::TypePath` is not satisfied
  --> src/test.rs:5:10
   |
5  | pub enum Action {
   |          ^^^^^^ the trait `bevy_reflect::type_path::TypePath` is not implemented for `test::Action`
   |
   = help: the following other types implement trait `bevy_reflect::type_path::TypePath`:
             bool
             char
             isize
             i8
             i16
             i32
             i64
             i128
           and 305 others
   = note: required for `test::Action` to implement `bevy_reflect::type_path::DynamicTypePath`
   = note: required for `test::Action` to implement `bevy_reflect::reflect::Reflect`
note: required by a bound in `leafwing_input_manager::Actionlike`
  --> ~/.cargo/git/checkouts/leafwing-input-manager-85f1d55581648fda/972978f/src/lib.rs:84:64
   |
84 | pub trait Actionlike: Eq + Hash + Send + Sync + Clone + Hash + Reflect + 'static {
   |                                                                ^^^^^^^ required by this bound in `Actionlike`
   = note: `Actionlike` is a "sealed trait", because to implement it you also need to implement `bevy_reflect::reflect::Reflect`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it

I tried bisecting bevy but something is really weird: It does build with bevy 0.11.3 from crates.io, but not with the tagged commit (972978f just changes the error message).

@alice-i-cecile
Copy link
Contributor

Might be conflicting versions of the Reflect trait? Check if you have multiple copies of Bevy in tree with cargo tree. And/or try out #401. I don't think @100-TomatoJuice reported this sort of problem there.

@Austreelis
Copy link
Author

Oooh right: lwim depends on bevy 0.11, so my crate depending on bevy main (0.12.0-dev, semver-incompatible) will always have two copies of bevy, and the traits are incompatible:

// lib.rs

use bevy::reflect::Reflect; // <- reflect from bevy 0.12 ------------------.
use leafwing_input_manager::Actionlike; // <- wants Reflect from bevy 0.11 |
//             _____________________________/                             /
//            /            ______________________________________________/
//           /            /
//          v            v
#[derive(Actionlike, Reflect, Hash, PartialEq, Eq, Clone, Copy, Debug)]
pub enum Action {
    Move,
    Jump,
}

So I need to explicitly depend on two versions of bevy if I want to keep using both main branches.

Sorry for the confusion !

@alice-i-cecile
Copy link
Contributor

No worries, thanks for investigating!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants