diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-04-06 07:44:21 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-04-06 13:01:14 -0700 |
| commit | d985344b933f2ccc07602fdf86fda94bc3e643cf (patch) | |
| tree | f98a1ec949da99e5497ea48a77733baf087583f9 /src/libproc_macro | |
| parent | a143462783cec88b7b733e8aa09990bfeb59f754 (diff) | |
| download | rust-d985344b933f2ccc07602fdf86fda94bc3e643cf.tar.gz rust-d985344b933f2ccc07602fdf86fda94bc3e643cf.zip | |
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
Diffstat (limited to 'src/libproc_macro')
| -rw-r--r-- | src/libproc_macro/lib.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 32697e46a08..836dc772f0f 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -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()) } |
