@@ -161,27 +161,29 @@ impl From<fallback::TokenStream> for TokenStream {
161
161
// Assumes inside_proc_macro().
162
162
fn into_compiler_token ( token : TokenTree ) -> proc_macro:: TokenTree {
163
163
match token {
164
- TokenTree :: Group ( tt) => tt. inner . unwrap_nightly ( ) . into ( ) ,
164
+ TokenTree :: Group ( tt) => proc_macro :: TokenTree :: from ( tt. inner . unwrap_nightly ( ) ) ,
165
165
TokenTree :: Punct ( tt) => {
166
166
let spacing = match tt. spacing ( ) {
167
167
Spacing :: Joint => proc_macro:: Spacing :: Joint ,
168
168
Spacing :: Alone => proc_macro:: Spacing :: Alone ,
169
169
} ;
170
170
let mut punct = proc_macro:: Punct :: new ( tt. as_char ( ) , spacing) ;
171
171
punct. set_span ( tt. span ( ) . inner . unwrap_nightly ( ) ) ;
172
- punct . into ( )
172
+ proc_macro :: TokenTree :: from ( punct )
173
173
}
174
- TokenTree :: Ident ( tt) => tt. inner . unwrap_nightly ( ) . into ( ) ,
175
- TokenTree :: Literal ( tt) => tt. inner . unwrap_nightly ( ) . into ( ) ,
174
+ TokenTree :: Ident ( tt) => proc_macro :: TokenTree :: from ( tt. inner . unwrap_nightly ( ) ) ,
175
+ TokenTree :: Literal ( tt) => proc_macro :: TokenTree :: from ( tt. inner . unwrap_nightly ( ) ) ,
176
176
}
177
177
}
178
178
179
179
impl From < TokenTree > for TokenStream {
180
180
fn from ( token : TokenTree ) -> Self {
181
181
if inside_proc_macro ( ) {
182
- TokenStream :: Compiler ( DeferredTokenStream :: new ( into_compiler_token ( token) . into ( ) ) )
182
+ TokenStream :: Compiler ( DeferredTokenStream :: new ( proc_macro:: TokenStream :: from (
183
+ into_compiler_token ( token) ,
184
+ ) ) )
183
185
} else {
184
- TokenStream :: Fallback ( token . into ( ) )
186
+ TokenStream :: Fallback ( fallback :: TokenStream :: from ( token ) )
185
187
}
186
188
}
187
189
}
@@ -336,18 +338,24 @@ impl Iterator for TokenTreeIter {
336
338
TokenTreeIter :: Fallback ( iter) => return iter. next ( ) ,
337
339
} ;
338
340
Some ( match token {
339
- proc_macro:: TokenTree :: Group ( tt) => crate :: Group :: _new ( Group :: Compiler ( tt) ) . into ( ) ,
341
+ proc_macro:: TokenTree :: Group ( tt) => {
342
+ TokenTree :: from ( crate :: Group :: _new ( Group :: Compiler ( tt) ) )
343
+ }
340
344
proc_macro:: TokenTree :: Punct ( tt) => {
341
345
let spacing = match tt. spacing ( ) {
342
346
proc_macro:: Spacing :: Joint => Spacing :: Joint ,
343
347
proc_macro:: Spacing :: Alone => Spacing :: Alone ,
344
348
} ;
345
349
let mut o = Punct :: new ( tt. as_char ( ) , spacing) ;
346
350
o. set_span ( crate :: Span :: _new ( Span :: Compiler ( tt. span ( ) ) ) ) ;
347
- o. into ( )
351
+ TokenTree :: from ( o)
352
+ }
353
+ proc_macro:: TokenTree :: Ident ( s) => {
354
+ TokenTree :: from ( crate :: Ident :: _new ( Ident :: Compiler ( s) ) )
355
+ }
356
+ proc_macro:: TokenTree :: Literal ( l) => {
357
+ TokenTree :: from ( crate :: Literal :: _new ( Literal :: Compiler ( l) ) )
348
358
}
349
- proc_macro:: TokenTree :: Ident ( s) => crate :: Ident :: _new ( Ident :: Compiler ( s) ) . into ( ) ,
350
- proc_macro:: TokenTree :: Literal ( l) => crate :: Literal :: _new ( Literal :: Compiler ( l) ) . into ( ) ,
351
359
} )
352
360
}
353
361
0 commit comments