@@ -117,14 +117,15 @@ impl FromStr for TokenStream {
117117 proc_macro_parse ( src) ?,
118118 ) ) )
119119 } else {
120- Ok ( TokenStream :: Fallback ( src . parse ( ) ?) )
120+ Ok ( TokenStream :: Fallback ( fallback :: TokenStream :: from_str ( src ) ?) )
121121 }
122122 }
123123}
124124
125125// Work around https://github.com/rust-lang/rust/issues/58736.
126126fn proc_macro_parse ( src : & str ) -> Result < proc_macro:: TokenStream , LexError > {
127- let result = panic:: catch_unwind ( || src. parse ( ) . map_err ( LexError :: Compiler ) ) ;
127+ let result =
128+ panic:: catch_unwind ( || proc_macro:: TokenStream :: from_str ( src) . map_err ( LexError :: Compiler ) ) ;
128129 result. unwrap_or_else ( |_| Err ( LexError :: CompilerPanic ) )
129130}
130131
@@ -147,7 +148,9 @@ impl From<TokenStream> for proc_macro::TokenStream {
147148 fn from ( inner : TokenStream ) -> Self {
148149 match inner {
149150 TokenStream :: Compiler ( inner) => inner. into_token_stream ( ) ,
150- TokenStream :: Fallback ( inner) => inner. to_string ( ) . parse ( ) . unwrap ( ) ,
151+ TokenStream :: Fallback ( inner) => {
152+ proc_macro:: TokenStream :: from_str ( & inner. to_string ( ) ) . unwrap ( )
153+ }
151154 }
152155 }
153156}
@@ -897,7 +900,7 @@ impl Literal {
897900 #[ cfg( no_literal_byte_character) ]
898901 {
899902 let fallback = fallback:: Literal :: byte_character ( byte) ;
900- fallback . repr . parse :: < proc_macro:: Literal > ( ) . unwrap ( )
903+ proc_macro:: Literal :: from_str ( & fallback . repr ) . unwrap ( )
901904 }
902905 } )
903906 } else {
@@ -924,7 +927,7 @@ impl Literal {
924927 #[ cfg( no_literal_c_string) ]
925928 {
926929 let fallback = fallback:: Literal :: c_string ( string) ;
927- fallback . repr . parse :: < proc_macro:: Literal > ( ) . unwrap ( )
930+ proc_macro:: Literal :: from_str ( & fallback . repr ) . unwrap ( )
928931 }
929932 } )
930933 } else {
0 commit comments