Skip to content

"proc-macro derive panicked" when deriving WorldQuery. #4533

Closed

Description

@linkpy

Bevy version

0.7.0

Operating system & version

Pop_OS! 21.10

What you did

#[derive(Component)]
struct Comp1;

#[derive(Component)]
struct Comp2;

#[derive(Component)]
struct Comp3;

#[derive(WorldQuery)]
struct WithoutComps {
  _1: Without<Comp1>,
  _2: Without<Comp2>,
  _3: Without<Comp3>
}

What you expected to happen

The project to compile.

What actually happened

$ cargo run
   Compiling somegame v0.1.0 (/home/pancake/Documents/dev/rust/somegame)
error: proc-macro derive panicked
  --> src/main.rs:29:10
   |
29 | #[derive(WorldQuery)]
   |          ^^^^^^^^^^
   |
   = help: message: called `Option::unwrap()` on a `None` value

Activity

  1. added
    C-BugAn unexpected or incorrect behavior
    S-Needs-TriageThis issue needs to be labelled
    on Apr 19, 2022
  2. added
    A-ECSEntities, components, systems, and events
    on Apr 19, 2022
  3. bjorn3 commented on Apr 19, 2022

    @bjorn3
    Contributor

    I'm getting

    error: proc-macro derive panicked
      --> src/main.rs:16:10
       |
    16 | #[derive(WorldQuery)]
       |          ^^^^^^^^^^
       |
       = help: message: Expected a struct with a lifetime

    instead when using bevy_ecs directly.

  4. added
    S-Needs-InvestigationThis issue requires detective work to figure out what's going wrong
    and removed
    S-Needs-TriageThis issue needs to be labelled
    on Apr 19, 2022
  5. CGMossa commented on Apr 19, 2022

    @CGMossa
    Contributor

    With the help of @Gibonus on discord, the fix for this is:

    #[derive(WorldQuery)]
    struct WithoutComps<'w> {
      _1: Without<Comp1>,
      _2: Without<Comp2>,
      _3: Without<Comp3>,
      #[world_query(ignore)]
      _fix: Option<&'w ()>
    }
  6. BoxyUwU commented on Apr 28, 2022

    @BoxyUwU
    Member

    This has been fixed by #3001

    #[derive(WorldQuery)]
    struct Foo {
        _1: Without<A>,
       _2: Without<B>,
        _3: Without<C>
    }

    will just work:tm: now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions