Auto merge of #53304 - dtolnay:extend, r=dtolnay

TokenStream::extend

Two new insta-stable impls in libproc_macro:

```rust
impl Extend<TokenTree> for TokenStream
impl Extend<TokenStream> for TokenStream
```

`proc_macro::TokenStream` already implements `FromIterator<TokenTree>` and `FromIterator<TokenStream>` so I elected to support the same input types for `Extend`.

**This commit reduces compile time of Serde derives by 60% (takes less than half as long to compile)** as measured by building our test suite:

```console
$ git clone https://github.com/serde-rs/serde
$ cd serde/test_suite
$ cargo check --tests --features proc-macro2/nightly
$ rm -f ../target/debug/deps/libtest_*.rmeta
$ time cargo check --tests --features proc-macro2/nightly
Before: 20.8 seconds
After: 8.6 seconds
```

r? @alexcrichton
This commit is contained in:
bors
2018-08-16 15:44:30 +00:00
4 changed files with 279 additions and 16 deletions

View File

@@ -130,6 +130,9 @@ pub mod util {
mod rc_slice;
pub use self::rc_slice::RcSlice;
mod rc_vec;
pub use self::rc_vec::RcVec;
}
pub mod json;