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

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

Closed
linkpy opened this issue Apr 19, 2022 · 3 comments
Closed

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

linkpy opened this issue Apr 19, 2022 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior

Comments

@linkpy
Copy link

linkpy commented Apr 19, 2022

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
@linkpy linkpy added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 19, 2022
@bjorn3 bjorn3 added the A-ECS Entities, components, systems, and events label Apr 19, 2022
@bjorn3
Copy link
Contributor

bjorn3 commented Apr 19, 2022

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.

@bjorn3 bjorn3 added S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Apr 19, 2022
@CGMossa
Copy link
Contributor

CGMossa commented Apr 19, 2022

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 ()>
}

@alice-i-cecile alice-i-cecile removed the S-Needs-Investigation This issue requires detective work to figure out what's going wrong label Apr 19, 2022
@BoxyUwU
Copy link
Member

BoxyUwU commented Apr 28, 2022

This has been fixed by #3001

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

will just work:tm: now

@BoxyUwU BoxyUwU closed this as completed Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants