bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.46k stars 3.6k forks source link

Use the fully qualified name for `Component` in the require `attribute` #16377

Closed venhelhardt closed 2 weeks ago

venhelhardt commented 2 weeks ago

Bevy version

The release number or commit hash of the version you're using. 7477928f1380ef8c56c00f184b7401c5afdcf678

What you did

Tried to compile this sample code:

#[derive(::bevy::ecs::component::Component, Default)]
pub struct A;

#[derive(::bevy::ecs::component::Component)]
#[require(A)]
pub struct B;

What went wrong

Compiler emits an error

11 | #[derive(::bevy::ecs::component::Component)]
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
   |
   = note: this error originates in the derive macro `::bevy::ecs::component::Component` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this trait
   |
1  + use bevy::prelude::Component;

Additional information

Problematic line: https://github.com/bevyengine/bevy/blob/7477928f1380ef8c56c00f184b7401c5afdcf678/crates/bevy_ecs/macros/src/component.rs#L85

Instead of <#ident as Component> it should be <#ident as #bevy_ecs_path::component::Component>