Skip to content

Commit d985344

Browse files
committed
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
1 parent a143462 commit d985344

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
@@ -141,9 +141,16 @@ impl From<TokenTree> for TokenStream {
141141
#[unstable(feature = "proc_macro", issue = "38356")]
142142
impl iter::FromIterator<TokenTree> for TokenStream {
143143
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self {
144+
trees.into_iter().map(TokenStream::from).collect()
145+
}
146+
}
147+
148+
#[unstable(feature = "proc_macro", issue = "38356")]
149+
impl iter::FromIterator<TokenStream> for TokenStream {
150+
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
144151
let mut builder = tokenstream::TokenStreamBuilder::new();
145-
for tree in trees {
146-
builder.push(tree.to_internal());
152+
for stream in streams {
153+
builder.push(stream.0);
147154
}
148155
TokenStream(builder.build())
149156
}

0 commit comments

Comments
 (0)