Skip to content

Commit 18524e1

Browse files
committed
Work around for macro parsing bug in rustc.
cc: hannobraun#5, rust-lang/rust#18775
1 parent cd844f9 commit 18524e1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

rustecs_macros/src/generate/intermediate.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,25 @@ impl Component {
6363
self.$collection.remove(&id);
6464
);
6565

66+
/* Todo: Parenthesis after $foo: are currently required in quote_tokens! to work around
67+
* ambiguity between macro-by-example $name:kind style matchers. Clean up once
68+
* rust-lang/rust#18775 is fixed.
69+
*/
6670
let field_decl = quote_tokens!(context,
67-
pub $var_name: Option<$ty>,
71+
pub $var_name: (Option<$ty>),
6872
);
6973
let field_init = quote_tokens!(context,
70-
$var_name: None,
74+
$var_name: (None),
7175
);
7276
let field_set = quote_tokens!(context,
73-
$var_name: self.$collection.pop(id),
77+
$var_name: (self.$collection.pop(id)),
7478
);
7579

7680
let collection_decl = quote_tokens!(context,
77-
pub $collection: _r::rustecs::Components<$ty>,
81+
pub $collection: (_r::rustecs::Components<$ty>),
7882
);
7983
let collection_init = quote_tokens!(context,
80-
$collection: _r::rustecs::components(),
84+
$collection: (_r::rustecs::components()),
8185
);
8286
let collection_arg = quote_tokens!(context,
8387
&mut _entities.$collection,

0 commit comments

Comments
 (0)