Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions crates/bevy_reflect/derive/src/derive_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
};
use bevy_macro_utils::ResultSifter;
use quote::{format_ident, quote, ToTokens};
use syn::token::Comma;
use syn::{token::Comma, MacroDelimiter};

use crate::enum_utility::{EnumVariantOutputData, ReflectCloneVariantBuilder, VariantBuilder};
use crate::field_attributes::CloneBehavior;
Expand Down Expand Up @@ -197,7 +197,16 @@ impl<'a> ReflectDerive<'a> {
for attribute in &input.attrs {
match &attribute.meta {
Meta::List(meta_list) if meta_list.path.is_ident(REFLECT_ATTRIBUTE_NAME) => {
container_attributes.parse_meta_list(meta_list, provenance.trait_)?;
if let MacroDelimiter::Paren(_) = meta_list.delimiter {
container_attributes.parse_meta_list(meta_list, provenance.trait_)?;
} else {
return Err(syn::Error::new(
meta_list.delimiter.span().join(),
format_args!(
"`#[{REFLECT_ATTRIBUTE_NAME}(\"...\")]` must use parentheses `(` and `)`"
),
));
}
}
Meta::NameValue(pair) if pair.path.is_ident(TYPE_PATH_ATTRIBUTE_NAME) => {
let syn::Expr::Lit(syn::ExprLit {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/sync_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Plugin for SyncWorldPlugin {
/// [`ExtractComponentPlugin`]: crate::extract_component::ExtractComponentPlugin
/// [`SyncComponentPlugin`]: crate::sync_component::SyncComponentPlugin
#[derive(Component, Copy, Clone, Debug, Default, Reflect)]
#[reflect[Component, Default, Clone]]
#[reflect(Component, Default, Clone)]
#[component(storage = "SparseSet")]
pub struct SyncToRenderWorld;

Expand Down
25 changes: 25 additions & 0 deletions release-content/migration-guides/reflect_parentheses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "`#[reflect(...)]` now supports only parentheses"
pull_requests: [21400]
---

Previously, the `#[reflect(...)]` attribute of the `Reflect` derive macro
supported parentheses, braces, or brackets. Now it supports only parentheses.

```rust
/// before
#[derive(Clone, Reflect)
#[reflect[Clone]]

/// after
#[derive(Clone, Reflect)
#[reflect(Clone)]

/// before
#[derive(Clone, Reflect)
#[reflect{Clone}]

/// after
#[derive(Clone, Reflect)
#[reflect(Clone)]
```