@@ -191,6 +191,14 @@ impl ToString for TokenStream {
191
191
/// Prints the token stream as a string that is supposed to be losslessly convertible back
192
192
/// into the same token stream (modulo spans), except for possibly `TokenTree::Group`s
193
193
/// with `Delimiter::None` delimiters and negative numeric literals.
194
+ ///
195
+ /// Note: the exact form of the output is subject to change, e.g. there might
196
+ /// be changes in the whitespace used between tokens. Therefore, you should
197
+ /// *not* do any kind of simple substring matching on the output string (as
198
+ /// produced by `to_string`) to implement a proc macro, because that matching
199
+ /// might stop working if such changes happen. Instead, you should work at the
200
+ /// `TokenTree` level, e.g. matching against `TokenTree::Ident`,
201
+ /// `TokenTree::Punct`, or `TokenTree::Literal`.
194
202
#[ stable( feature = "proc_macro_lib" , since = "1.15.0" ) ]
195
203
impl fmt:: Display for TokenStream {
196
204
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -758,6 +766,14 @@ impl ToString for TokenTree {
758
766
/// Prints the token tree as a string that is supposed to be losslessly convertible back
759
767
/// into the same token tree (modulo spans), except for possibly `TokenTree::Group`s
760
768
/// with `Delimiter::None` delimiters and negative numeric literals.
769
+ ///
770
+ /// Note: the exact form of the output is subject to change, e.g. there might
771
+ /// be changes in the whitespace used between tokens. Therefore, you should
772
+ /// *not* do any kind of simple substring matching on the output string (as
773
+ /// produced by `to_string`) to implement a proc macro, because that matching
774
+ /// might stop working if such changes happen. Instead, you should work at the
775
+ /// `TokenTree` level, e.g. matching against `TokenTree::Ident`,
776
+ /// `TokenTree::Punct`, or `TokenTree::Literal`.
761
777
#[ stable( feature = "proc_macro_lib2" , since = "1.29.0" ) ]
762
778
impl fmt:: Display for TokenTree {
763
779
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
0 commit comments