@@ -16,7 +16,7 @@ use unicode_xid::UnicodeXID;
1616
1717use { Delimiter , Group , Op , Spacing , TokenTree } ;
1818
19- #[ derive( Clone , Debug ) ]
19+ #[ derive( Clone ) ]
2020pub struct TokenStream {
2121 inner : Vec < TokenTree > ,
2222}
@@ -111,6 +111,13 @@ impl fmt::Display for TokenStream {
111111 }
112112}
113113
114+ impl fmt:: Debug for TokenStream {
115+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
116+ f. write_str ( "TokenStream " ) ?;
117+ f. debug_list ( ) . entries ( self . clone ( ) ) . finish ( )
118+ }
119+ }
120+
114121#[ cfg( feature = "proc-macro" ) ]
115122impl From < :: proc_macro:: TokenStream > for TokenStream {
116123 fn from ( inner : :: proc_macro:: TokenStream ) -> TokenStream {
@@ -314,7 +321,7 @@ impl Codemap {
314321 }
315322}
316323
317- #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
324+ #[ derive( Clone , Copy , PartialEq , Eq ) ]
318325pub struct Span {
319326 #[ cfg( procmacro2_semver_exempt) ]
320327 lo : u32 ,
@@ -393,6 +400,16 @@ impl Span {
393400 }
394401}
395402
403+ impl fmt:: Debug for Span {
404+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
405+ #[ cfg( procmacro2_semver_exempt) ]
406+ return write ! ( f, "bytes({}..{})" , self . lo, self . hi) ;
407+
408+ #[ cfg( not( procmacro2_semver_exempt) ) ]
409+ write ! ( f, "Span" )
410+ }
411+ }
412+
396413#[ derive( Copy , Clone ) ]
397414pub struct Term {
398415 intern : usize ,
@@ -466,7 +483,11 @@ fn validate_term(string: &str) {
466483
467484impl fmt:: Debug for Term {
468485 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
469- f. debug_tuple ( "Term" ) . field ( & self . as_str ( ) ) . finish ( )
486+ let mut debug = f. debug_struct ( "Term" ) ;
487+ debug. field ( "sym" , & format_args ! ( "{}" , self . as_str( ) ) ) ;
488+ #[ cfg( procmacro2_semver_exempt) ]
489+ debug. field ( "span" , & self . span ) ;
490+ debug. finish ( )
470491 }
471492}
472493
@@ -508,7 +529,7 @@ impl Interner {
508529 }
509530}
510531
511- #[ derive( Clone , Debug ) ]
532+ #[ derive( Clone ) ]
512533pub struct Literal {
513534 text : String ,
514535 span : Span ,
@@ -629,6 +650,16 @@ impl fmt::Display for Literal {
629650 }
630651}
631652
653+ impl fmt:: Debug for Literal {
654+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
655+ let mut debug = fmt. debug_struct ( "Literal" ) ;
656+ debug. field ( "lit" , & format_args ! ( "{}" , self . text) ) ;
657+ #[ cfg( procmacro2_semver_exempt) ]
658+ debug. field ( "span" , & self . span ) ;
659+ debug. finish ( )
660+ }
661+ }
662+
632663fn token_stream ( mut input : Cursor ) -> PResult < :: TokenStream > {
633664 let mut trees = Vec :: new ( ) ;
634665 loop {
0 commit comments