You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Syntax extensions (apparently) can not return multiple items. #16723
Since #10649, macro_rules! macros can return multiple items. But there is no easy way to do so from a syntax extension: the result value must implement MacResult and the appropriate implementation appear to be MacItem, but it can only hold one item.
In servo/servo#3142, I worked around this with a new MacItems (plural) type:
structMacItems{items:SmallVector<Gc<ast::Item>>}implMacItems{fnnew<I:Iterator<Gc<ast::Item>>>(items:I) -> Box<MacResult>{
box MacItems{items: items.collect()}asBox<MacResult>}implMacResultforMacItems{fnmake_items(&self) -> Option<SmallVector<Gc<ast::Item>>>{// FIXME: Implement Clone on SmallVector and use it instead of .iter().collect()Some(self.items.iter().collect())}}
Perhaps this could be added to libsyntax or merged with MacItem.
Activity
huonw commentedon Sep 5, 2014
Seems reasonable to just extend
MacItem(tagging as easy since a perfectly good implementation is in the issue :) ).Allow syntax extensions to return multiple items, closes rust-lang#16723
Auto merge of rust-lang#16723 - norskeld:constants-autocomplete, r=Ve…