@@ -167,9 +167,9 @@ impl TokenStream {
167
167
/// separating the two arguments with a comma for diagnostic suggestions.
168
168
pub ( crate ) fn add_comma ( & self ) -> Option < ( TokenStream , Span ) > {
169
169
// Used to suggest if a user writes `foo!(a b);`
170
- if let TokenStreamKind :: Stream ( ref slice ) = self . kind {
170
+ if let TokenStreamKind :: Stream ( ref stream ) = self . kind {
171
171
let mut suggestion = None ;
172
- let mut iter = slice . iter ( ) . enumerate ( ) . peekable ( ) ;
172
+ let mut iter = stream . iter ( ) . enumerate ( ) . peekable ( ) ;
173
173
while let Some ( ( pos, ts) ) = iter. next ( ) {
174
174
if let Some ( ( _, next) ) = iter. peek ( ) {
175
175
let sp = match ( & ts. kind , & next. kind ) {
@@ -189,13 +189,12 @@ impl TokenStream {
189
189
}
190
190
}
191
191
if let Some ( ( pos, comma, sp) ) = suggestion {
192
- let mut new_slice = vec ! [ ] ;
193
- let parts = slice. split_at ( pos + 1 ) ;
194
- new_slice. extend_from_slice ( parts. 0 ) ;
195
- new_slice. push ( comma) ;
196
- new_slice. extend_from_slice ( parts. 1 ) ;
197
- let slice = Lrc :: new ( new_slice) ;
198
- return Some ( ( TokenStream { kind : TokenStreamKind :: Stream ( slice) } , sp) ) ;
192
+ let mut new_stream = vec ! [ ] ;
193
+ let parts = stream. split_at ( pos + 1 ) ;
194
+ new_stream. extend_from_slice ( parts. 0 ) ;
195
+ new_stream. push ( comma) ;
196
+ new_stream. extend_from_slice ( parts. 1 ) ;
197
+ return Some ( ( TokenStream :: concat ( new_stream) , sp) ) ;
199
198
}
200
199
}
201
200
None
@@ -273,12 +272,7 @@ impl Extend<TokenStream> for TokenStream {
273
272
// Build the resulting token stream. If it contains more than one token,
274
273
// preserve capacity in the vector in anticipation of the caller
275
274
// performing additional calls to extend.
276
- let mut tts = builder. 0 ;
277
- * self = match tts. len ( ) {
278
- 0 => TokenStream :: empty ( ) ,
279
- 1 => tts. pop ( ) . unwrap ( ) ,
280
- _ => TokenStream :: concat_rc_vec ( Lrc :: new ( tts) ) ,
281
- } ;
275
+ * self = TokenStream :: concat ( builder. 0 ) ;
282
276
}
283
277
}
284
278
@@ -483,7 +477,7 @@ impl TokenStreamBuilder {
483
477
match len {
484
478
1 => { }
485
479
2 => self . 0 . push ( streams[ 0 ] . clone ( ) . into ( ) ) ,
486
- _ => self . 0 . push ( TokenStream :: concat_rc_vec ( Lrc :: new ( streams[ 0 .. len - 1 ] . to_vec ( ) ) ) ) ,
480
+ _ => self . 0 . push ( TokenStream :: concat ( streams[ 0 .. len - 1 ] . to_vec ( ) ) ) ,
487
481
}
488
482
self . push_all_but_last_tree ( & streams[ len - 1 ] )
489
483
}
@@ -495,7 +489,7 @@ impl TokenStreamBuilder {
495
489
match len {
496
490
1 => { }
497
491
2 => self . 0 . push ( streams[ 1 ] . clone ( ) . into ( ) ) ,
498
- _ => self . 0 . push ( TokenStream :: concat_rc_vec ( Lrc :: new ( streams[ 1 .. len] . to_vec ( ) ) ) ) ,
492
+ _ => self . 0 . push ( TokenStream :: concat ( streams[ 1 .. len] . to_vec ( ) ) ) ,
499
493
}
500
494
self . push_all_but_first_tree ( & streams[ 0 ] )
501
495
}
0 commit comments