rust-lang/rust — pull request #17236 by fhahn (2014-09-13 17:39:52+00:00)
Title: Allow syntax extensions to return multiple items, closes #16723

This is PR is basically the change proposed by @SimonSapin. I can also extend MacItem, as @huonw suggested, but I'm not sure how that was meant exactly. A comment for MacItem states that it's a convenience type for macros that return a single item. Should I adapt MacItem to contain a SmallVector of items instead of a single item and update the comment?

And I've two questions concerning the patch.

First, I am not sure what's the best way to duplicate the SmallVector holding the items. The way I'm doing it at the moment strikes me as suboptimal (https://github.com/fhahn/rust/compare/issue-16723-multiple-items?expand=1#diff-5100da09ad52c81568562e36ee359343R241). An additional map() call is required, because `iter()` returns an iterator to pointers to the elements. Is there a better way? Should I open a ticket and implement `clone()` for `SmallVector`?

And second, I had problems running the test in the test suite because it complains that there is no name `MacItems` in `syntax::base::ext` although there is. When I compile the file with

LD_LIBRARY_PATH=x86_64-unknown-linux-gnu/stage2/lib/
x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc
-L x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/
src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs

it works. But I'm not sure which `rustc` binary should be used, e.g. there is on stage1 build in `x86_64-unknown-linux-gnu/stage1/bin/rustc` and one in ` x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc `.