@@ -497,42 +497,40 @@ impl TokenStreamBuilder {
497
497
498
498
// If `self` is not empty and the last tree within the last stream is a
499
499
// token tree marked with `Joint`...
500
- if let Some ( TokenStream ( ref mut last_stream_lrc) ) = self . 0 . last_mut ( ) {
501
- if let Some ( ( TokenTree :: Token ( last_token) , Spacing :: Joint ) ) = last_stream_lrc. last ( ) {
502
- // ...and `stream` is not empty and the first tree within it is
503
- // a token tree...
504
- let TokenStream ( ref mut stream_lrc) = stream;
505
- if let Some ( ( TokenTree :: Token ( token) , spacing) ) = stream_lrc. first ( ) {
506
- // ...and the two tokens can be glued together...
507
- if let Some ( glued_tok) = last_token. glue ( & token) {
508
- // ...then do so, by overwriting the last token
509
- // tree in `self` and removing the first token tree
510
- // from `stream`. This requires using `make_mut()`
511
- // on the last stream in `self` and on `stream`,
512
- // and in practice this doesn't cause cloning 99.9%
513
- // of the time.
514
-
515
- // Overwrite the last token tree with the merged
516
- // token.
517
- let last_vec_mut = Lrc :: make_mut ( last_stream_lrc) ;
518
- * last_vec_mut. last_mut ( ) . unwrap ( ) = ( TokenTree :: Token ( glued_tok) , * spacing) ;
519
-
520
- // Remove the first token tree from `stream`. (This
521
- // is almost always the only tree in `stream`.)
522
- let stream_vec_mut = Lrc :: make_mut ( stream_lrc) ;
523
- stream_vec_mut. remove ( 0 ) ;
524
-
525
- // Don't push `stream` if it's empty -- that could
526
- // block subsequent token gluing, by getting
527
- // between two token trees that should be glued
528
- // together.
529
- if !stream. is_empty ( ) {
530
- self . 0 . push ( stream) ;
531
- }
532
- return ;
533
- }
534
- }
500
+ if let Some ( TokenStream ( ref mut last_stream_lrc) ) = self . 0 . last_mut ( )
501
+ && let Some ( ( TokenTree :: Token ( last_token) , Spacing :: Joint ) ) = last_stream_lrc. last ( )
502
+ // ...and `stream` is not empty and the first tree within it is
503
+ // a token tree...
504
+ && let TokenStream ( ref mut stream_lrc) = stream
505
+ && let Some ( ( TokenTree :: Token ( token) , spacing) ) = stream_lrc. first ( )
506
+ // ...and the two tokens can be glued together...
507
+ && let Some ( glued_tok) = last_token. glue ( & token)
508
+ {
509
+ // ...then do so, by overwriting the last token
510
+ // tree in `self` and removing the first token tree
511
+ // from `stream`. This requires using `make_mut()`
512
+ // on the last stream in `self` and on `stream`,
513
+ // and in practice this doesn't cause cloning 99.9%
514
+ // of the time.
515
+
516
+ // Overwrite the last token tree with the merged
517
+ // token.
518
+ let last_vec_mut = Lrc :: make_mut ( last_stream_lrc) ;
519
+ * last_vec_mut. last_mut ( ) . unwrap ( ) = ( TokenTree :: Token ( glued_tok) , * spacing) ;
520
+
521
+ // Remove the first token tree from `stream`. (This
522
+ // is almost always the only tree in `stream`.)
523
+ let stream_vec_mut = Lrc :: make_mut ( stream_lrc) ;
524
+ stream_vec_mut. remove ( 0 ) ;
525
+
526
+ // Don't push `stream` if it's empty -- that could
527
+ // block subsequent token gluing, by getting
528
+ // between two token trees that should be glued
529
+ // together.
530
+ if !stream. is_empty ( ) {
531
+ self . 0 . push ( stream) ;
535
532
}
533
+ return ;
536
534
}
537
535
self . 0 . push ( stream) ;
538
536
}
0 commit comments