Skip to content

Commit 574c050

Browse files
committed
Rollup merge of rust-lang#49734 - alexcrichton:generalize-token-stream, r=nikomatsakis
proc_macro: Generalize `FromIterator` impl 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 rust-lang#49597 Closes rust-lang#49725
2 parents 57b15f6 + d985344 commit 574c050

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/libproc_macro/lib.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,16 @@ impl From<TokenTree> for TokenStream {
140140
#[unstable(feature = "proc_macro", issue = "38356")]
141141
impl iter::FromIterator<TokenTree> for TokenStream {
142142
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self {
143+
trees.into_iter().map(TokenStream::from).collect()
144+
}
145+
}
146+
147+
#[unstable(feature = "proc_macro", issue = "38356")]
148+
impl iter::FromIterator<TokenStream> for TokenStream {
149+
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
143150
let mut builder = tokenstream::TokenStreamBuilder::new();
144-
for tree in trees {
145-
builder.push(tree.to_internal());
151+
for stream in streams {
152+
builder.push(stream.0);
146153
}
147154
TokenStream(builder.build())
148155
}

0 commit comments

Comments
 (0)