From d985344b933f2ccc07602fdf86fda94bc3e643cf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 6 Apr 2018 07:44:21 -0700 Subject: [PATCH] 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 #49597 Closes #49725 --- src/libproc_macro/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 32697e46a08ac..836dc772f0fea 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -141,9 +141,16 @@ impl From for TokenStream { #[unstable(feature = "proc_macro", issue = "38356")] impl iter::FromIterator for TokenStream { fn from_iter>(trees: I) -> Self { + trees.into_iter().map(TokenStream::from).collect() + } +} + +#[unstable(feature = "proc_macro", issue = "38356")] +impl iter::FromIterator for TokenStream { + fn from_iter>(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()) }