X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibsyntax%2Ftokenstream.rs;h=a220ba0a5ea2ce5434e2d750da6834188c055089;hb=90b8d34c9f0d17c948801f676a96800e8b038508;hp=ac155556cdae25d541ca79c82b947409d0c3b58f;hpb=bd82de0de69d72fcdb9054c70d2a1ee8328e5480;p=rust.git diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index ac155556cda..a220ba0a5ea 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -19,7 +19,6 @@ #[cfg(target_arch = "x86_64")] use rustc_data_structures::static_assert_size; use rustc_data_structures::sync::Lrc; -use rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; use smallvec::{SmallVec, smallvec}; use std::{iter, mem}; @@ -136,7 +135,7 @@ pub fn close_tt(span: Span, delim: DelimToken) -> TokenTree { /// The goal is for procedural macros to work with `TokenStream`s and `TokenTree`s /// instead of a representation of the abstract syntax tree. /// Today's `TokenTree`s can still contain AST via `token::Interpolated` for back-compat. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, RustcEncodable, RustcDecodable)] pub struct TokenStream(pub Lrc>); pub type TreeAndJoint = (TokenTree, IsJoint); @@ -145,7 +144,7 @@ pub fn close_tt(span: Span, delim: DelimToken) -> TokenTree { #[cfg(target_arch = "x86_64")] static_assert_size!(TokenStream, 8); -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, RustcDecodable)] pub enum IsJoint { Joint, NonJoint @@ -254,7 +253,7 @@ pub fn len(&self) -> usize { // Get the first stream. If it's `None`, create an empty // stream. - let mut iter = streams.drain(); + let mut iter = streams.drain(..); let mut first_stream_lrc = iter.next().unwrap().0; // Append the elements to the first stream, after reserving @@ -460,18 +459,6 @@ pub fn look_ahead(&self, n: usize) -> Option { } } -impl Encodable for TokenStream { - fn encode(&self, encoder: &mut E) -> Result<(), E::Error> { - self.trees().collect::>().encode(encoder) - } -} - -impl Decodable for TokenStream { - fn decode(decoder: &mut D) -> Result { - Vec::::decode(decoder).map(|vec| vec.into_iter().collect()) - } -} - #[derive(Debug, Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct DelimSpan { pub open: Span,