@@ -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 ;
@@ -305,7 +305,7 @@ pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
305
305
token:: NtIdent ( e, is_raw) => IdentPrinter :: for_ast_ident ( e, is_raw) . to_string ( ) ,
306
306
token:: NtLifetime ( e) => e. to_string ( ) ,
307
307
token:: NtLiteral ( ref e) => expr_to_string ( e) ,
308
- token:: NtTT ( ref tree) => tt_to_string ( tree. clone ( ) ) ,
308
+ token:: NtTT ( ref tree) => tt_to_string ( tree) ,
309
309
token:: NtVis ( ref e) => vis_to_string ( e) ,
310
310
}
311
311
}
@@ -326,11 +326,11 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
326
326
to_string ( |s| s. print_expr ( e) )
327
327
}
328
328
329
- pub fn tt_to_string ( tt : tokenstream :: TokenTree ) -> String {
329
+ pub fn tt_to_string ( tt : & TokenTree ) -> String {
330
330
to_string ( |s| s. print_tt ( tt, false ) )
331
331
}
332
332
333
- pub fn tts_to_string ( tokens : TokenStream ) -> String {
333
+ pub fn tts_to_string ( tokens : & TokenStream ) -> String {
334
334
to_string ( |s| s. print_tts ( tokens, false ) )
335
335
}
336
336
@@ -597,7 +597,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
597
597
false ,
598
598
None ,
599
599
delim. to_token ( ) ,
600
- tokens. clone ( ) ,
600
+ tokens,
601
601
true ,
602
602
span,
603
603
) ,
@@ -606,7 +606,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
606
606
if let MacArgs :: Eq ( _, tokens) = & item. args {
607
607
self . space ( ) ;
608
608
self . word_space ( "=" ) ;
609
- self . print_tts ( tokens. clone ( ) , true ) ;
609
+ self . print_tts ( tokens, true ) ;
610
610
}
611
611
}
612
612
}
@@ -647,9 +647,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
647
647
/// appropriate macro, transcribe back into the grammar we just parsed from,
648
648
/// and then pretty-print the resulting AST nodes (so, e.g., we print
649
649
/// expression arguments as expressions). It can be done! I think.
650
- fn print_tt ( & mut self , tt : tokenstream :: TokenTree , convert_dollar_crate : bool ) {
650
+ fn print_tt ( & mut self , tt : & TokenTree , convert_dollar_crate : bool ) {
651
651
match tt {
652
- TokenTree :: Token ( ref token) => {
652
+ TokenTree :: Token ( token) => {
653
653
self . word ( token_to_string_ext ( & token, convert_dollar_crate) ) ;
654
654
if let token:: DocComment ( ..) = token. kind {
655
655
self . hardbreak ( )
@@ -660,7 +660,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
660
660
None ,
661
661
false ,
662
662
None ,
663
- delim,
663
+ * delim,
664
664
tts,
665
665
convert_dollar_crate,
666
666
dspan. entire ( ) ,
@@ -669,14 +669,14 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
669
669
}
670
670
}
671
671
672
- fn print_tts ( & mut self , tts : tokenstream :: TokenStream , convert_dollar_crate : bool ) {
673
- let mut iter = tts. into_trees ( ) . peekable ( ) ;
672
+ fn print_tts ( & mut self , tts : & TokenStream , convert_dollar_crate : bool ) {
673
+ let mut iter = tts. trees ( ) . peekable ( ) ;
674
674
while let Some ( tt) = iter. next ( ) {
675
- let show_space =
676
- if let Some ( next) = iter. peek ( ) { tt_prepend_space ( next , & tt ) } else { false } ;
677
- self . print_tt ( tt , convert_dollar_crate ) ;
678
- if show_space {
679
- self . space ( ) ;
675
+ self . print_tt ( & tt , convert_dollar_crate ) ;
676
+ if let Some ( next) = iter. peek ( ) {
677
+ if tt_prepend_space ( next , & tt ) {
678
+ self . space ( ) ;
679
+ }
680
680
}
681
681
}
682
682
}
@@ -687,7 +687,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
687
687
has_bang : bool ,
688
688
ident : Option < Ident > ,
689
689
delim : DelimToken ,
690
- tts : TokenStream ,
690
+ tts : & TokenStream ,
691
691
convert_dollar_crate : bool ,
692
692
span : Span ,
693
693
) {
@@ -1265,7 +1265,7 @@ impl<'a> State<'a> {
1265
1265
has_bang,
1266
1266
Some ( item. ident ) ,
1267
1267
macro_def. body . delim ( ) ,
1268
- macro_def. body . inner_tokens ( ) ,
1268
+ & macro_def. body . inner_tokens ( ) ,
1269
1269
true ,
1270
1270
item. span ,
1271
1271
) ;
@@ -1589,7 +1589,7 @@ impl<'a> State<'a> {
1589
1589
true ,
1590
1590
None ,
1591
1591
m. args . delim ( ) ,
1592
- m. args . inner_tokens ( ) ,
1592
+ & m. args . inner_tokens ( ) ,
1593
1593
true ,
1594
1594
m. span ( ) ,
1595
1595
) ;
0 commit comments