File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -245,11 +245,13 @@ impl FromStr for TokenStream {
245245 type Err = LexError ;
246246
247247 fn from_str ( src : & str ) -> Result < TokenStream , LexError > {
248- let e = imp:: TokenStream :: from_str ( src) . map_err ( |e| LexError {
249- inner : e,
250- _marker : MARKER ,
251- } ) ?;
252- Ok ( TokenStream :: _new ( e) )
248+ match imp:: TokenStream :: from_str ( src) {
249+ Ok ( tokens) => Ok ( TokenStream :: _new ( tokens) ) ,
250+ Err ( lex) => Err ( LexError {
251+ inner : lex,
252+ _marker : MARKER ,
253+ } ) ,
254+ }
253255 }
254256}
255257
@@ -1307,12 +1309,13 @@ impl FromStr for Literal {
13071309 type Err = LexError ;
13081310
13091311 fn from_str ( repr : & str ) -> Result < Self , LexError > {
1310- imp:: Literal :: from_str ( repr)
1311- . map ( Literal :: _new)
1312- . map_err ( |inner| LexError {
1313- inner,
1312+ match imp:: Literal :: from_str ( repr) {
1313+ Ok ( lit ) => Ok ( Literal :: _new ( lit ) ) ,
1314+ Err ( lex ) => Err ( LexError {
1315+ inner : lex ,
13141316 _marker : MARKER ,
1315- } )
1317+ } ) ,
1318+ }
13161319 }
13171320}
13181321
Original file line number Diff line number Diff line change @@ -124,9 +124,10 @@ impl FromStr for TokenStream {
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 =
128- panic:: catch_unwind ( || proc_macro:: TokenStream :: from_str ( src) . map_err ( LexError :: Compiler ) ) ;
129- result. unwrap_or_else ( |_| Err ( LexError :: CompilerPanic ) )
127+ match panic:: catch_unwind ( || proc_macro:: TokenStream :: from_str ( src) ) {
128+ Ok ( result) => result. map_err ( LexError :: Compiler ) ,
129+ Err ( _) => Err ( LexError :: CompilerPanic ) ,
130+ }
130131}
131132
132133impl Display for TokenStream {
You can’t perform that action at this time.
0 commit comments