@@ -100,7 +100,7 @@ pub fn is_available() -> bool {
100100#[ cfg_attr( feature = "rustc-dep-of-std" , rustc_diagnostic_item = "TokenStream" ) ]
101101#[ stable( feature = "proc_macro_lib" , since = "1.15.0" ) ]
102102#[ derive( Clone ) ]
103- pub struct TokenStream ( Rc < Vec < bridge:: TokenTree < bridge:: client:: Span , bridge:: client:: Symbol > > > ) ;
103+ pub struct TokenStream ( bridge:: TokenStream < bridge:: client:: Span , bridge:: client:: Symbol > ) ;
104104
105105#[ stable( feature = "proc_macro_lib" , since = "1.15.0" ) ]
106106impl !Send for TokenStream { }
@@ -154,13 +154,13 @@ impl TokenStream {
154154 /// Returns an empty `TokenStream` containing no token trees.
155155 #[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
156156 pub fn new ( ) -> TokenStream {
157- TokenStream ( Rc :: new ( Vec :: new ( ) ) )
157+ TokenStream ( bridge :: TokenStream :: new ( Vec :: new ( ) ) )
158158 }
159159
160160 /// Checks if this `TokenStream` is empty.
161161 #[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
162162 pub fn is_empty ( & self ) -> bool {
163- self . 0 . is_empty ( )
163+ self . 0 . trees . is_empty ( )
164164 }
165165
166166 /// Parses this `TokenStream` as an expression and attempts to expand any
@@ -175,8 +175,8 @@ impl TokenStream {
175175 /// considered errors, is unspecified and may change in the future.
176176 #[ unstable( feature = "proc_macro_expand" , issue = "90765" ) ]
177177 pub fn expand_expr ( & self ) -> Result < TokenStream , ExpandError > {
178- match BridgeMethods :: ts_expand_expr ( stream_to_bridge_stream ( self . clone ( ) ) ) {
179- Ok ( stream) => Ok ( TokenStream ( Rc :: clone ( & stream. trees ) ) ) ,
178+ match BridgeMethods :: ts_expand_expr ( self . 0 . clone ( ) ) {
179+ Ok ( stream) => Ok ( TokenStream ( stream) ) ,
180180 Err ( _) => Err ( ExpandError ) ,
181181 }
182182 }
@@ -194,7 +194,7 @@ impl FromStr for TokenStream {
194194 type Err = LexError ;
195195
196196 fn from_str ( src : & str ) -> Result < TokenStream , LexError > {
197- Ok ( TokenStream ( Rc :: clone ( & BridgeMethods :: ts_from_str ( src) . trees ) ) )
197+ Ok ( TokenStream ( BridgeMethods :: ts_from_str ( src) ) )
198198 }
199199}
200200
@@ -212,7 +212,7 @@ impl FromStr for TokenStream {
212212#[ stable( feature = "proc_macro_lib" , since = "1.15.0" ) ]
213213impl fmt:: Display for TokenStream {
214214 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
215- write ! ( f, "{}" , BridgeMethods :: ts_to_string( stream_to_bridge_stream ( self . clone( ) ) ) )
215+ write ! ( f, "{}" , BridgeMethods :: ts_to_string( self . 0 . clone( ) ) )
216216 }
217217}
218218
@@ -235,12 +235,6 @@ impl Default for TokenStream {
235235#[ unstable( feature = "proc_macro_quote" , issue = "54722" ) ]
236236pub use quote:: { HasIterator , RepInterp , ThereIsNoIteratorInRepetition , ext, quote, quote_span} ;
237237
238- fn stream_to_bridge_stream (
239- stream : TokenStream ,
240- ) -> bridge:: TokenStream < bridge:: client:: Span , bridge:: client:: Symbol > {
241- bridge:: TokenStream { trees : stream. 0 . clone ( ) }
242- }
243-
244238fn tree_to_bridge_tree (
245239 tree : TokenTree ,
246240) -> bridge:: TokenTree < bridge:: client:: Span , bridge:: client:: Symbol > {
@@ -256,7 +250,7 @@ fn tree_to_bridge_tree(
256250#[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
257251impl From < TokenTree > for TokenStream {
258252 fn from ( tree : TokenTree ) -> TokenStream {
259- TokenStream ( Rc :: new ( vec ! [ tree_to_bridge_tree( tree) ] ) )
253+ TokenStream ( bridge :: TokenStream :: new ( vec ! [ tree_to_bridge_tree( tree) ] ) )
260254 }
261255}
262256
@@ -276,14 +270,14 @@ impl ConcatTreesHelper {
276270 }
277271
278272 fn build ( self ) -> TokenStream {
279- TokenStream ( Rc :: new ( self . trees ) )
273+ TokenStream ( bridge :: TokenStream :: new ( self . trees ) )
280274 }
281275
282276 fn append_to ( mut self , stream : & mut TokenStream ) {
283277 if self . trees . is_empty ( ) {
284278 return ;
285279 }
286- Rc :: make_mut ( & mut stream. 0 ) . append ( & mut self . trees ) ;
280+ Rc :: make_mut ( & mut stream. 0 . trees ) . append ( & mut self . trees ) ;
287281 }
288282}
289283
@@ -314,9 +308,9 @@ impl ConcatStreamsHelper {
314308 if self . streams . is_empty ( ) {
315309 return ;
316310 }
317- let this = Rc :: make_mut ( & mut stream. 0 ) ;
311+ let this = Rc :: make_mut ( & mut stream. 0 . trees ) ;
318312 for mut s in self . streams {
319- this. append ( Rc :: make_mut ( & mut s. 0 ) ) ;
313+ this. append ( Rc :: make_mut ( & mut s. 0 . trees ) ) ;
320314 }
321315 }
322316}
@@ -423,7 +417,7 @@ pub mod token_stream {
423417 type IntoIter = IntoIter ;
424418
425419 fn into_iter ( self ) -> IntoIter {
426- IntoIter ( Rc :: unwrap_or_clone ( self . 0 ) . into_iter ( ) )
420+ IntoIter ( Rc :: unwrap_or_clone ( self . 0 . trees ) . into_iter ( ) )
427421 }
428422 }
429423}
@@ -801,7 +795,7 @@ impl Group {
801795 pub fn new ( delimiter : Delimiter , stream : TokenStream ) -> Group {
802796 Group ( bridge:: Group {
803797 delimiter,
804- stream : Some ( stream_to_bridge_stream ( stream) ) ,
798+ stream : Some ( stream. 0 ) ,
805799 span : bridge:: DelimSpan :: from_single ( Span :: call_site ( ) . 0 ) ,
806800 } )
807801 }
@@ -819,8 +813,8 @@ impl Group {
819813 #[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
820814 pub fn stream ( & self ) -> TokenStream {
821815 match & self . 0 . stream {
822- Some ( stream) => TokenStream ( Rc :: clone ( & stream. trees ) ) ,
823- None => TokenStream ( Rc :: new ( vec ! [ ] ) ) ,
816+ Some ( stream) => TokenStream ( stream. clone ( ) ) ,
817+ None => TokenStream ( bridge :: TokenStream :: new ( vec ! [ ] ) ) ,
824818 }
825819 }
826820
0 commit comments