Cannot find derive macro, attribute and implementation

Hello again!

So I am exploring ECS with this tutorial (@alice I am sorry, I did not watch the video you recommended yet -I have to plan those 42 minutes ^^- so I hope those questions are relevant).
I ran into 3 errors that are very confusing:

1. not implemented :face_with_monocle:
^^^^^^^^ the trait specs::world::comp::Component is not implemented for Position

The tutorial does not implement anything at this stage, so I added

impl Component for Position {
    type Storage = VecStorage<Self>;

as per the specs docs. Is it correct and all that needs to be done?

2. cannot find attribute :face_with_monocle: :face_with_monocle: and 3. cannot derive macro :face_with_monocle: :face_with_monocle: :face_with_monocle:
cannot find attribute storage in this scope
cannot find derive macro Component in this scope

According to SO, it should be very easy to solve. Make sure Cargo.toml has the required dependencies, and I have (added specs-derive just to be sure!!)

specs= {version = "0.15.0", feature = ["specs-derive"]}
specs-derive = "0.4.1"

and make sure you have imported the derive and crate with use, which I have:

use specs::{
    join::Join, Builder, Component, ReadStorage, RunNow, System, VecStorage, World, WorldExt,

I even tried to run the author's code to make sure it was not a typo but it produces the same errors.

What shall I do to fix the errors?

Component is supposed to be implemented for Position by the derive macro. #[derive(Debug, Component, Clone, Copy)] basically means "generate an implementation of Debug, Component, Clone and Copy for the type below". But because there was an error cannot find derive macro Component in this scope, the implementation was not generated.

For me, simply importing the traits being used was enough to make it compile (I did not add specs-derive to Cargo.toml). use specs::{Component, VecStorage};

1 Like

Thank you, I had not understand that!

EDIT: I am sorry. I found the error.
I forgot the "s" in features :woman_facepalming:t5:. I have been spoiled by the compiler so far in my debugging, and could not understand this one.

Thank you a lot for testing (that's when I thought that might be my import that's wrong :D) and explaining about how the macros was generating implementations :rose:

EDIT2: Btw, why don't we have a syntax checker in Cargo.toml file?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.