@@ -9,7 +9,7 @@ use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
9
9
use rustc_ast:: attr;
10
10
use rustc_ast:: ptr:: P ;
11
11
use rustc_ast:: token:: { self , BinOpToken , DelimToken , Nonterminal , Token , TokenKind } ;
12
- use rustc_ast:: tokenstream:: { self , TokenStream , TokenTree } ;
12
+ use rustc_ast:: tokenstream:: { TokenStream , TokenTree } ;
13
13
use rustc_ast:: util:: parser:: { self , AssocOp , Fixity } ;
14
14
use rustc_ast:: util:: { classify, comments} ;
15
15
use rustc_span:: edition:: Edition ;
@@ -293,7 +293,7 @@ pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
293
293
token:: NtIdent ( e, is_raw) => IdentPrinter :: for_ast_ident ( e, is_raw) . to_string ( ) ,
294
294
token:: NtLifetime ( e) => e. to_string ( ) ,
295
295
token:: NtLiteral ( ref e) => expr_to_string ( e) ,
296
- token:: NtTT ( ref tree) => tt_to_string ( tree. clone ( ) ) ,
296
+ token:: NtTT ( ref tree) => tt_to_string ( tree) ,
297
297
token:: NtVis ( ref e) => vis_to_string ( e) ,
298
298
}
299
299
}
@@ -314,11 +314,11 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
314
314
to_string ( |s| s. print_expr ( e) )
315
315
}
316
316
317
- pub fn tt_to_string ( tt : tokenstream :: TokenTree ) -> String {
317
+ pub fn tt_to_string ( tt : & TokenTree ) -> String {
318
318
to_string ( |s| s. print_tt ( tt, false ) )
319
319
}
320
320
321
- pub fn tts_to_string ( tokens : TokenStream ) -> String {
321
+ pub fn tts_to_string ( tokens : & TokenStream ) -> String {
322
322
to_string ( |s| s. print_tts ( tokens, false ) )
323
323
}
324
324
@@ -585,7 +585,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
585
585
false ,
586
586
None ,
587
587
delim. to_token ( ) ,
588
- tokens. clone ( ) ,
588
+ tokens,
589
589
true ,
590
590
span,
591
591
) ,
@@ -594,7 +594,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
594
594
if let MacArgs :: Eq ( _, tokens) = & item. args {
595
595
self . space ( ) ;
596
596
self . word_space ( "=" ) ;
597
- self . print_tts ( tokens. clone ( ) , true ) ;
597
+ self . print_tts ( tokens, true ) ;
598
598
}
599
599
}
600
600
}
@@ -635,9 +635,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
635
635
/// appropriate macro, transcribe back into the grammar we just parsed from,
636
636
/// and then pretty-print the resulting AST nodes (so, e.g., we print
637
637
/// expression arguments as expressions). It can be done! I think.
638
- fn print_tt ( & mut self , tt : tokenstream :: TokenTree , convert_dollar_crate : bool ) {
638
+ fn print_tt ( & mut self , tt : & TokenTree , convert_dollar_crate : bool ) {
639
639
match tt {
640
- TokenTree :: Token ( ref token) => {
640
+ TokenTree :: Token ( token) => {
641
641
self . word ( token_to_string_ext ( & token, convert_dollar_crate) ) ;
642
642
if let token:: DocComment ( ..) = token. kind {
643
643
self . hardbreak ( )
@@ -648,7 +648,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
648
648
None ,
649
649
false ,
650
650
None ,
651
- delim,
651
+ * delim,
652
652
tts,
653
653
convert_dollar_crate,
654
654
dspan. entire ( ) ,
@@ -657,14 +657,14 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
657
657
}
658
658
}
659
659
660
- fn print_tts ( & mut self , tts : tokenstream :: TokenStream , convert_dollar_crate : bool ) {
661
- let mut iter = tts. into_trees ( ) . peekable ( ) ;
660
+ fn print_tts ( & mut self , tts : & TokenStream , convert_dollar_crate : bool ) {
661
+ let mut iter = tts. trees ( ) . peekable ( ) ;
662
662
while let Some ( tt) = iter. next ( ) {
663
- let show_space =
664
- if let Some ( next) = iter. peek ( ) { tt_prepend_space ( next , & tt ) } else { false } ;
665
- self . print_tt ( tt , convert_dollar_crate ) ;
666
- if show_space {
667
- self . space ( ) ;
663
+ self . print_tt ( & tt , convert_dollar_crate ) ;
664
+ if let Some ( next) = iter. peek ( ) {
665
+ if tt_prepend_space ( next , & tt ) {
666
+ self . space ( ) ;
667
+ }
668
668
}
669
669
}
670
670
}
@@ -675,7 +675,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
675
675
has_bang : bool ,
676
676
ident : Option < Ident > ,
677
677
delim : DelimToken ,
678
- tts : TokenStream ,
678
+ tts : & TokenStream ,
679
679
convert_dollar_crate : bool ,
680
680
span : Span ,
681
681
) {
@@ -1253,7 +1253,7 @@ impl<'a> State<'a> {
1253
1253
has_bang,
1254
1254
Some ( item. ident ) ,
1255
1255
macro_def. body . delim ( ) ,
1256
- macro_def. body . inner_tokens ( ) ,
1256
+ & macro_def. body . inner_tokens ( ) ,
1257
1257
true ,
1258
1258
item. span ,
1259
1259
) ;
@@ -1577,7 +1577,7 @@ impl<'a> State<'a> {
1577
1577
true ,
1578
1578
None ,
1579
1579
m. args . delim ( ) ,
1580
- m. args . inner_tokens ( ) ,
1580
+ & m. args . inner_tokens ( ) ,
1581
1581
true ,
1582
1582
m. span ( ) ,
1583
1583
) ;
0 commit comments