Skip to content

Commit

Permalink
Cleanup has_reflect_attr
Browse files Browse the repository at this point in the history
  • Loading branch information
james7132 committed Mar 9, 2024
1 parent 5aa2fa9 commit a8950a6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions crates/bevy_ecs/macros/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,16 @@ fn has_reflect_attr(ast: &DeriveInput, reflect_trait: &'static str) -> bool {

const REFLECT: &str = "reflect";
ast.attrs.iter().any(|attr| {
if !attr.path().is_ident(REFLECT) {
if !attr.path().is_ident(REFLECT) || !matches!(attr.meta, Meta::List(_)) {
return false;
}

if !matches!(attr.meta, Meta::List(_)) {
return false;
}

let mut is_component_registered = false;

attr.parse_nested_meta(|meta| {
is_component_registered |= meta.path.is_ident(reflect_trait);
Ok(())
meta.path.is_ident(reflect_trait)
.then(|| ())
.ok_or_else(|| meta.error("missing required reflect attribute"))
})
.ok();

is_component_registered
.is_ok()
})
}

Expand Down

0 comments on commit a8950a6

Please sign in to comment.