Skip to content

Commit

Permalink
proc_macro: Generalize FromIterator impl
Browse files Browse the repository at this point in the history
While never intended to be stable we forgot that trait impls are insta-stable!
This construction of `FromIterator` wasn't our first choice of how to stabilize
the impl but our hands are tied at this point, so revert back to the original
definition of `FromIterator` before #49597

Closes #49725
  • Loading branch information
alexcrichton committed Apr 6, 2018
1 parent a143462 commit d985344
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,16 @@ impl From<TokenTree> for TokenStream {
#[unstable(feature = "proc_macro", issue = "38356")]
impl iter::FromIterator<TokenTree> for TokenStream {
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self {
trees.into_iter().map(TokenStream::from).collect()
}
}

#[unstable(feature = "proc_macro", issue = "38356")]
impl iter::FromIterator<TokenStream> for TokenStream {
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
let mut builder = tokenstream::TokenStreamBuilder::new();
for tree in trees {
builder.push(tree.to_internal());
for stream in streams {
builder.push(stream.0);
}
TokenStream(builder.build())
}
Expand Down

0 comments on commit d985344

Please sign in to comment.