Ralith / hecs

A handy ECS
Apache License 2.0
967 stars 82 forks source link

can't derive Query #309

Closed SArpnt closed 1 year ago

SArpnt commented 1 year ago

i made a new crate with cargo init, created this Cargo.toml

[package]
name = "hecs-test"
version = "0.1.0"
edition = "2021"

[dependencies]
hecs = { version = "0.10.0", features = ["macros"] }

and made this src/main.rs

use hecs::*;

#[derive(Query)]
struct Test<'a>;

fn main() {}

i get many errors:

error[E0437]: type `Item` is not a member of trait `hecs::Fetch`
 --> src/main.rs:3:10
  |
3 | #[derive(Query)]
  |          ^^^^^ not a member of trait `hecs::Fetch`
  |
  = note: this error originates in the derive macro `Query` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `get` is not a member of trait `hecs::Fetch`
 --> src/main.rs:3:10
  |
3 | #[derive(Query)]
  |          ^^^^^ not a member of trait `hecs::Fetch`
  |
  = note: this error originates in the derive macro `Query` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
  --> src/main.rs:3:10
   |
3  | #[derive(Query)]
   |          ^^^^^- help: remove these generics
   |          |
   |          expected 0 lifetime arguments
   |
note: trait defined here, with 0 lifetime parameters
  --> /home/sarpnt/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/hecs-0.10.0/src/query.rs:48:18
   |
48 | pub unsafe trait Fetch: Sized {
   |                  ^^^^^
   = note: this error originates in the derive macro `Query` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
 --> src/main.rs:3:10
  |
3 | #[derive(Query)]
  |          ^^^^^- help: remove these generics
  |          |
  |          expected 0 lifetime arguments
  |
note: struct defined here, with 0 lifetime parameters
 --> src/main.rs:3:10
  |
3 | #[derive(Query)]
  |          ^^^^^
  = note: this error originates in the derive macro `Query` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0220]: associated type `Item` not found for `Self`
 --> src/main.rs:3:10
  |
3 | #[derive(Query)]
  |          ^^^^^ associated type `Item` not found
  |
  = note: this error originates in the derive macro `Query` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0107, E0220, E0407, E0437.
For more information about an error, try `rustc --explain E0107`.

i can't think of any more information i would be able to give, the macro backtrace isn't helpful, it just points to the macro's function signature.

Ralith commented 1 year ago

Looks like we forgot to bump hecs-macros following some recent breakage, and tests didn't catch this because they all use a path dep. Fixed in 0.10.1. Thanks for the report!