]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #65641 - nnethercote:derive-TokenStream-Encodable-Decodable, r=petroc...
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 23 Oct 2019 20:19:16 +0000 (22:19 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Oct 2019 20:19:16 +0000 (22:19 +0200)
Derive `Rustc{En,De}codable` for `TokenStream`.

`TokenStream` used to be a complex type, but it is now just a newtype
around a `Lrc<Vec<TreeAndJoint>>`. Currently it uses custom encoding
that discards the `IsJoint` and custom decoding that adds `NonJoint`
back in for every token tree. This requires building intermediate
`Vec<TokenTree>`s.

This commit makes `TokenStream` derive `Rustc{En,De}codable`. This
simplifies the code, and avoids the creation of the intermediate
vectors, saving up to 3% on various benchmarks. It also changes the AST
JSON output in one test.

r? @petrochenkov


Trivial merge