@@ -410,19 +410,6 @@ impl TokenStream {
410410 TokenStream ( Lrc :: new ( self . 0 . iter ( ) . enumerate ( ) . map ( |( i, tree) | f ( i, tree) ) . collect ( ) ) )
411411 }
412412
413- fn opt_from_ast ( node : & ( impl HasAttrs + HasTokens ) ) -> Option < TokenStream > {
414- let tokens = node. tokens ( ) ?;
415- let attrs = node. attrs ( ) ;
416- let attr_stream = if attrs. is_empty ( ) {
417- tokens. create_token_stream ( )
418- } else {
419- let attr_data =
420- AttributesData { attrs : attrs. iter ( ) . cloned ( ) . collect ( ) , tokens : tokens. clone ( ) } ;
421- AttrTokenStream :: new ( vec ! [ AttrTokenTree :: Attributes ( attr_data) ] )
422- } ;
423- Some ( attr_stream. to_tokenstream ( ) )
424- }
425-
426413 // Create a token stream containing a single token with alone spacing.
427414 pub fn token_alone ( kind : TokenKind , span : Span ) -> TokenStream {
428415 TokenStream :: new ( vec ! [ TokenTree :: token_alone( kind, span) ] )
@@ -439,8 +426,18 @@ impl TokenStream {
439426 }
440427
441428 pub fn from_ast ( node : & ( impl HasAttrs + HasSpan + HasTokens + fmt:: Debug ) ) -> TokenStream {
442- TokenStream :: opt_from_ast ( node)
443- . unwrap_or_else ( || panic ! ( "missing tokens for node at {:?}: {:?}" , node. span( ) , node) )
429+ let Some ( tokens) = node. tokens ( ) else {
430+ panic ! ( "missing tokens for node at {:?}: {:?}" , node. span( ) , node) ;
431+ } ;
432+ let attrs = node. attrs ( ) ;
433+ let attr_stream = if attrs. is_empty ( ) {
434+ tokens. create_token_stream ( )
435+ } else {
436+ let attr_data =
437+ AttributesData { attrs : attrs. iter ( ) . cloned ( ) . collect ( ) , tokens : tokens. clone ( ) } ;
438+ AttrTokenStream :: new ( vec ! [ AttrTokenTree :: Attributes ( attr_data) ] )
439+ } ;
440+ attr_stream. to_tokenstream ( )
444441 }
445442
446443 pub fn from_nonterminal_ast ( nt : & Nonterminal ) -> TokenStream {
0 commit comments